The company I work for has an in-house administrative side to our site. I’ve noticed its running alot slower and I’m assuming its not because the side of our database but the way we are making the calls and rendering them out to the screen. I’m going to list out an example of our process to render stuff out and hopefully someone can tell me where we are doing it inefficiently to help speed up render loading times.
//Student Page:
Avg. Loading Time: 5 - 6 seconds
//table_user:
Columns Records
45 16,412
//table_use_course:
Columns Records
22 18,623
//Indexing:
Comment: We use plesk (phpmyadmin) and this is where I did the indexing.
I indexed all primary and foreign keys and it looks like this:
//Query:
SELECT a.account_id, user_id, user_first_name, user_last_name
FROM table_user a
INNER JOIN table_user_course b ON a.account_id = b.account_id
WHERE user_active = 'yes' AND b.product_type_id = '1'
ORDER BY user_first_name ASC LIMIT 0, 30
//Query Results:
Columns Records
4 30
//How we render:
if(is_array($query_results)){
foreach($querY_results as $student){
$text .= $student['user_first_name'], $student['user_last_name'], etc.
}
}
Additional Thoughts:
We do have a test site with the same code and database structure, just a lot less data in the db. The test site runs much quicker which makes me think its how we pull it from the database. On the other hand 16k – 18k records isn’t that much and I’m surprised and the difference in loading time between the test site and the live site.
Any help or suggestions on how to make things run quicker would be much appreciated!
2
Answers
While indexing, one need to focus in the columns used in the
inner
part… in your case:In both tables. Try that and clarify if you have already done
Example:
Source: How do I add indices to MySQL tables?
For your case, use:
And add (only if they don’t already exist):
Perhaps the performance issue isn’t on the database. Trace the page execution with http://www.xdebug.org it will tell, for each line in source, execution time and memory usage.