MySQL – Excellent performance with good planning
This is nothing new to add to the world of comparisons, but I felt it worth clarifying a few points that I - someone who's not a complete pro, yet not a novice -- I'd say intermediate developer - have learned about working with MySQL in terms of when to use what and improving efficiency based on an average of all information researched, and the results I achieved.
Normally, most of my work has been with small low traffic websites for various small businesses where efficiency planning was mostly too time consuming for the cost. Recently have been working on higher traffic applications and after running into a "too many connections" issue during peak hours tried many initial steps at alleviating the problem, such as increasing efficiency in my database abstraction class (starting with lazy loading), and releasing result sets asap among a few others. Each step added a performance gain, but not until all matters were taken into account did it make a difference.
These changes quickly formed into my personal list of best practices and good habits to get into.
A few rules of thumb that have served me well:
__PHP_Incomplete_Class as array
Regarding something to which I found no straight answer in 8 pages of google results:
"Fatal error: Cannot use object of type __PHP_Incomplete_Class as array in"
The offending line was the first instance of a session variable with a certain key name:
if (!isset($_SESSION['user'][0])) { $_SESSION['user'][0] = 0; }
On the development server there were no problems, but put on the demo shared server over which I have no control, the error appeared. I scoured the internet for the solution but it seems anyone who has this problem never really gets a straight answer - and it seems to come up a fair bit. Incidentally, it seems to be related usually to login/user/session management scripts since certain keywords are fairly common in those situations.
Frustrated, as a last ditch attempt I changed it to:
if (!isset($_SESSION['usrinf'][0])) { $_SESSION['usrinf'][0] = 0; }
The problem was solved instantly.
Turns out it was the key "user" which was the problem in the hosting environment.
So if anyone has this issue, do a find/replace of all instances of the session variable key located in the line indicated by the error to something more unique .