A VERY slow query

Sometimes this query runs very fast, other times it takes close to 40 seconds. Very frustrating. What are some reasons that would cause this variance?


select count(*) as total from notifications where mailingID = 61;

What indexes are in place for the notifications table?
How much does the number of records in the notifications table vary?
Are any other queries running at the same time as when this one is slow?

1 Like

Here is a screenshot of the indexes I have on the notifications table. My auto-increment notificationID column is well over 9,000,000, but I keep the table pruned and delete rows that are over 30 days. Right now the table is about 900MB in size, plus the indexes. I’m not exactly sure how to tell what other queries are running at the moment I experience this “slowness”. Any pointers would be greatly appreciated.


Try adding an index on mailingID

and do an EXPLAIN on the query to see the execution plan

if you do it before and after adding the index on mailingID, you should see a difference


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.