List:Internals« Previous MessageNext Message »
From:Michael Widenius Date:February 18 2009 1:39pm
Subject:re: comments and query cache
View as plain text  
Hi!

>>>>> "Eric" == Eric  <esquid2@stripped> writes:

Eric> Hi All-
Eric> AFAICT, query comments are used as part of the hash key for query cache (at
Eric> least in 5.0).  Is this intentional?  Still the case in newer versions of
Eric> mysql?

Yes;  It's mainly for speed but also because comments can affect the
way queries are executed (if you use optimizer hints)

<cut>

Eric> I have a patch (attached) to strip comments before checking and storing the
Eric> query into the query cache but wanted to see if this was a reasonable way to
Eric> do it.  Also, I couldn't find a very reasonable function to strip comments.
Eric> (The one in innobase/hash/hash0hash.c seemed the best, but I imagine it is
Eric> not fit to include so I copied it just to get my proof-of-concept working
Eric> until/if something better is decided.)

Don't know of any other function to do that.

Eric> If this seems useful and reasonable, is there a better way to get the
Eric> comments stripped?  Should I implement my own?  (Should be able to be done
Eric> in the existing char* without allocating any new memory, right?)

If you *only* strip safe comments (not using the /*!...*/ syntax you
can strip it in the original memory.

Eric> Does
Eric> InnoDB (what we use) or any other engine depend on the comments in any way
Eric> (I know oracle puts query hints in there)?  How should this behavior be
Eric> enabled since I imagine not everyone will want the runtime v. cache hit
Eric> tradeoff.  ./configure option?  my.cnf?  a dynamic variable?

You should have this either as a dynamic variable or a connection
option.  This is to not cause an extra parsing overhead in the case
where comments are static for the query.

Regards,
Monty
Thread
comments and query cacheEric17 Feb
  • Re: comments and query cacheAntony T Curtis18 Feb
  • re: comments and query cacheMichael Widenius18 Feb
    • RE: comments and query cacheRick James18 Feb
      • Re: comments and query cacheJocelyn Fournier19 Feb