TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

MySQL query comments in Rails

35 pointsby themcgruffabout 13 years ago

7 comments

tlackabout 13 years ago
I've been doing this on high traffic PHP sites for years. It makes mytop very informative and easy to understand, and I even occasionally use them for cheapo memcache caching instructions (built into db layer) when it's not worth precaching or coming up with a more sophisticated scheme. Highly recommended.<p>One difference though: I prepend the comment instead of appending it.
famousactressabout 13 years ago
I dig this, a lot. Anyone know if there's a Django equivalent yet? If not, I know what I'll be doing with at least one evening this week...
评论 #3885582 未加载
评论 #3885497 未加载
rosserabout 13 years ago
A similar thing I've tried to get implemented at a number of previous jobs is to dump the session ID in a SQL comment when issuing a query. We've had the session ID in application logs forever, but no way of correlating DB activity with application activity; this would fix that and allow <i>a posteriori</i> full-stack instrumentation.
评论 #3886737 未加载
eliabout 13 years ago
Note that adding comments to otherwise identical queries will typically cause the MySQL query cache to not realize they are the same. See: <a href="http://www.mysqlperformanceblog.com/2008/03/20/mysql-query-cache-whitespace-and-comments/" rel="nofollow">http://www.mysqlperformanceblog.com/2008/03/20/mysql-query-c...</a><p>Otherwise, neat idea, I like it.
评论 #3885494 未加载
评论 #3888291 未加载
Pewpewarrowsabout 13 years ago
Does Rails not have an equivalent to the Django-Debug-Toolbar to easily debug stuff like this in development?<p>As for production, going with a fleshed-out service like NewRelic makes more sense to me. If I see slow queries start happening I'd want a broader report of what's going on in my system, not just a map of the query to a controller/action.
billybobabout 13 years ago
That's pretty nice. It would also be nice for ActiveRecord migrations to let me add comments to the database and the schema file.
jhuckesteinabout 13 years ago
Does anyone know if this exists for postgres?
评论 #3886305 未加载
评论 #3887323 未加载