GET 24/7 LIVE HELP NOW

Announcement

Announcement Module
Collapse
No announcement yet.

Query Cache: evaluating whether a query is cacheable

Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

    Thanks

  • #2
    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.

    Comment


    • #3
      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?

      Thanks

      Comment


      • #4
        carpii wrote on Fri, 28 August 2009 16:14

        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?

        Thanks

        Duration. You could also check the status variables to see whether there was a hit on the query cache.

        Comment

        Working...
        X