0

I have a query like this :

SELECT SQL_NO_CACHE columns_names FROM table_name WHERE conditions;

I use SQL_NO_CACHE in order to measure the real execution time.

Here's the problem : the first query is sometimes way slower than next ones. For example, first query may take around 2-10s to execute and next queries take around 300ms to execute. Btw, I do have indexes to optimize my query.

It seems like the Database is sleeping when there's no action or something like that. Is there a way to prevent that ?

Philippe Genois
  • 599
  • 4
  • 6
  • See this question: http://stackoverflow.com/questions/6666631/sql-no-cache-does-not-work – jhaagsma Oct 22 '16 at 22:55
  • The database isn't "sleeping" but there are other cache/buffer mechanisms other than the query cache (which is what `SQL_NO_CACHE` disables) that may have held and then evicted the data because of other queries... even taking a backup can trigger this, but to get more specific, what storage engine are these tables using? Have you examined the query plans with `EXPLAIN SELECT ...` and confirmed that they are not only optimal, but that they don't tend to shift over time? – Michael - sqlbot Oct 23 '16 at 05:09
  • Thanks for your replies. The storage engine is MyISAM. What do you mean by 'shift over time' ? – Philippe Genois Oct 23 '16 at 14:46

0 Answers0