Query Cache: evaluating whether a query is cacheable

I read some time ago, that when MySQL is checking to see if a given query can be cached, all it does is check the query begins with ‘SELECT’.

Assuming this is or was true, can anyone confirm if its still the case on MySQL 5.x ?

In addition, if its true, what if the query begins with a comment?
I sometimes use short comments in the query, which helps debugging when looking at SHOW PROCESSLIST.

Ie, “/VW-HIT/ SELECT this, that from table”

Whilst this query will always have a comment of /VW-HIT/, I wonder if Im unintentionally bypassing the query cache because it doesnt being with “SELECT” ?

With any luck, Ive misunderstood and MySQL’s query cache is a little more intelligent than this anyway


Of course you can simply test this. i’ve tested it with MySQL 5.0.38, and comments in front of a query do not influence cacheability. So yup, query cache is more intelligent than this.

How are you testing whether its being cached or not?

Just by running a complex query and checking the duration, or is there some tools to inspect the query cache?