Home / Companies / PlanetScale / Blog / Post Details
Content Deep Dive

Identifying slow Rails queries with sqlcommenter

Blog post from PlanetScale

Post Details
Company
Date Published
Author
Mike Coutermarsh, Iheanyi Ekechukwu
Word Count
549
Language
English
Hacker News Points
6
Summary

In Rails 7, the Marginalia gem has been replaced by a native feature that adds comments to queries, making it easier to track down slow queries and improve performance. The new format is sqlcommenter#, which is machine-readable and more valuable in logging and performance monitoring tools. A gem for Rails 7 enables this feature, allowing developers to add comments to queries using the sqlcommenter# format. This gem also introduces a new method called annotate, which lets developers add specific comments to queries. The combination of Rails + sqlcommenter# + PlanetScale Query Insights can greatly improve query debugging experience and is recommended for Rails applications. PlanetScale's built-in query debugging and analysis tool is compatible with the sqlcommenter# format, allowing developers to quickly find and fix issues in their application.