-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the sampling of the pgsa query #255
base: master
Are you sure you want to change the base?
Conversation
It wrongly computes the sampling: the "total" column is not correct in this context: we (most of the time) have more than 1 record per sample. If you have 100 sessions, the sampling will be off by a factor of 100, and you'll end up with only 1 sample It's a bit ugly to fix, because we need another subquery... Closes #254
@@ -517,9 +517,9 @@ def BASE_QUERY_PGSA_SAMPLE(per_db=False): | |||
|
|||
# We use dense_rank() as we need ALL the records for a specific ts | |||
return """ | |||
(SELECT *,max(number) OVER () AS total FROM | |||
(SELECT pgsa_history.srvid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you indent this as this is now a sub query?
@@ -546,7 +546,7 @@ def BASE_QUERY_PGSA_SAMPLE(per_db=False): | |||
AND pgsac.srvid = %(server)s | |||
) AS pgsa_history | |||
{extra} | |||
) AS pgsa | |||
) AS temp) AS pgsa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: ideally we should avoid keywords here even if that seems to be allowed. maybe just tmp or something
yeah the need for a sub query is annoying. For the record some other db like duckdb now support a QUALIFY clause (https://duckdb.org/docs/sql/query_syntax/qualify.html) which fixes that problems. I implemented a prototype for postgres some months ago but never sent it. It's not part of the standard so I don't think it will be accepted. |
It wrongly computes the sampling: the "total" column is not correct in this context: we (most of the time) have more than 1 record per sample. If you have 100 sessions, the sampling will be off by a factor of 100, and you'll end up with only 1 sample
It's a bit ugly to fix, because we need another subquery...
Closes #254