Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions powa/sql/views_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Member

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?

dense_rank() OVER (ORDER BY pgsa_history.ts) AS number,
count(*) OVER () AS total,
ts,
datid,
cur_txid,
Expand All @@ -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
Copy link
Member

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

WHERE number %% ( int8larger((total)/(%(samples)s+1),1) ) = 0
""".format(extra=extra)

Expand Down