Replies: 1 comment 4 replies
-
Are inline comments showing up in pg_stat_statements and thus may flood that view with the same query if that query has been called from many locations (which would change the inline comment)? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Recently we added #3362 which when turned on include the "label" in generated SQL select queries. For query beans, this will automatically be the class and method that invoked the query.
Example:
This feature is really there to assist Database side tools that look for expensive queries in total time and slow queries etc.
Now having turned this on myself, I'm liking this feature when running tests and looking at SQL logs and that makes me think that maybe this feature should some day be on by default (and then people could configure to turn it off if they wished).
So I'm keen for people to turn this on themselves and ponder if there are any reasons why it should not be used or if you'd be happy for this feature to become on by default.
Thanks, Rob.
Some background:
From an application / ebean perspective we can obtain the query execution metrics (count, mean, max, total) via Database.metaInfo().collectMetrics(). Some applications will be collecting these metrics every minute and publishing them to a performance monitoring tool (like Grafana etc).
The Labels on these metrics for query bean queries are the same labels being included into the SQL as an inline comment.
Some details on Labels:
As a detail, you'll note that sometimes these have line numbers and most often they don't. The reason why we prefer to NOT include the line number is because we want these metric labels to be as stable as we can to compare how they change over time - if we include the line number then these can change frequently as new lines of code are added etc. The line number will be included when it is detected that there are multiple queries for the same type in the same method and at that point we know that the method name itself does not sufficiently identify where the query is executed from so we need to include the line number in the label.
As another detail, you'll note that secondary queries and lazy loading queries append as a path to the label of the "origin" query. For example let's say we have a label like "MyService.myMethod" where a query for orders is executed, we might have a label "MyService.myMethod_customer" (for a secondary query for the customer of an order). "MyService.myMethod_customer_billingAddress" (for a secondary query of the customers billing address). There is a "__lazy" suffix added when a secondary query is a lazy loading query.
Beta Was this translation helpful? Give feedback.
All reactions