Question

I am using Joomla and have a MySQL query which seem to take an extra long time to run. Run directly from PHPMyAdmin it is fine, from Joomla it takes about 429.19ms to run.

SELECT top_num_racers 
  FROM fej2l_raceresults_results 
  WHERE  state = 1 
  AND race_name = 'Race to Eliminate Sexual Violence' 
  AND sub_event = '5k' 
  AND race_date = '2014-04-26' 
  LIMIT 1

Looks like a pretty simple query, so what would slow this down? It is running directly in the view file, and not in the module, would that cause a slow down? Thanks for any help.

Page is here: http://premierraces.org/component/raceresults/?view=results&Itemid=300&rname=Race%20to%20Eliminate%20Sexual%20Violence&rsub=5k&rdate=2014-04-26

Was it helpful?

Solution

I'm surprised no answers yet, but my only suggestion is a compound index on multiple fields to cover the criteria you are looking for. I would suggest an index on

(race_date, state, sub_event, race_name)

Not to be confused with multiple indexes on the columns individually. By looking at other queries, and your table structure, the order of these fields in the index might be better served in alternate sequence, but not enough info to make that as a final call.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top