News for hackers. Stuff that matters.
Re:MySQL query comments in Rails by eli on Tuesday April 24, 2012 @02:11PM (#3885463)
Note that adding comments to otherwise identical queries will typically cause the MySQL query cache to not realize they are the same. See: http://www.mysqlperformanceblog.com/2008/03/20/mysql-query-c...

Otherwise, neat idea, I like it.

Re:MySQL query comments in Rails by themcgruff on Tuesday April 24, 2012 @02:16PM (#3885494)
Most, if not all production mysql installations have this cache disabled anyways. (Based on my experience at Engine Yard for 3 years and other places the last 5 years.)
Re:MySQL query comments in Rails by eli on Tuesday April 24, 2012 @11:04PM (#3887490)
I did not realize that. Interesting. Thanks!
Re:MySQL query comments in Rails by dholowiski on Tuesday April 24, 2012 @02:21PM (#3885525)
Why?
Re:MySQL query comments in Rails by ruckusing on Tuesday April 24, 2012 @08:53PM (#3887151)
Also the MySQL query cache is not very granular, it gets cleared on every write to that table. Thus, we've seen in practice that with it enabled MySQL has poorer performance as its constantly being flushed. The overhead of maintaining it doesnt pay off.

Of course its a trade-off. If you have have substantially more reads than writes than it might be OK for your needs.

Re:MySQL query comments in Rails by themcgruff on Tuesday April 24, 2012 @02:31PM (#3885586)
Mutex issues and other problems with high insert / update rates. Google "mysql query cache issues" and "mysql query cache disable" for lots of posts about the various costs / benefits.
Re:MySQL query comments in Rails by Gigablah on Wednesday April 25, 2012 @05:18AM (#3888291)
I think if you just prepend C-style comments (e.g. /* test */ SELECT...) it should still work with the query cache [1]. But leading line comments (like --) will not work [2].

[1] http://bugs.mysql.com/bug.php?id=824

[2] http://bugs.mysql.com/bug.php?id=40986