Enhanced tagging in Postgres Query Insights
Blog post from PlanetScale
Rafer Hazen's blog post discusses the enhancements made to the query tagging feature in Postgres Query Insights, introduced with the Traffic Control launch, which now allows tags to be present in aggregated query data. This advancement facilitates viewing tag distribution, searching queries by tag, and analyzing database statistics per tag. Tags, which are key-value pairs embedded in SQL comments, can be automatically applied at the application level, with Insights adding tags like application_name, username, and remote_address. The new feature provides multiple surfaces for viewing tags, including query patterns, database tags, and query filters. Implementation involves the Insights Postgres extension, Kafka, and ClickHouse, and the new capability addresses previous limitations by associating all query data with relevant tags. Although this increases the number of messages emitted due to unique tag combinations, strategies like cardinality reduction are employed to manage data volume. Cardinality reduction uses per-tag and per-interval limits to collapse high-cardinality tags, ensuring efficient data handling and message emission. The post concludes by highlighting the power of query tagging in providing comprehensive insight into database performance.