powa-team / powa

PostgreSQL Workload Analyzer
http://powa.readthedocs.io/
PostgreSQL License
778 stars 57 forks source link

glitch in summarizing query stats #51

Closed shribe closed 9 years ago

shribe commented 9 years ago

consider these entries from pg_stat_statements:

userid | dbid | queryid | query | calls | total_time | rows
--------+-------+------------+----------------------------------------------------+-------+------------------+------- 16384 | 16388 | 3025283004 | set search_path to v2,v0; select log.setup_conn(); | 210 | 290.964 | 210 16384 | 16388 | 1610272070 | set search_path to v2,v0; select log.setup_conn(); | 210 | 8.975 | 0 10 | 16388 | 3025283004 | set search_path to v2,v0; select log.setup_conn(); | 44052 | 1352.91499999995 | 44052 10 | 16388 | 1610272070 | set search_path to v2,v0; select log.setup_conn(); | 44052 | 250.063999999903 | 0

See the attached screenshot. remote desktopscreensnapz001

shribe commented 9 years ago

BTW, I apologize for putting these on the wrong repository. Forgot I was in docs, not where it belonged.

rdunklau commented 9 years ago

Thats fine, this repository acts as a catch-all for issues related to the various components.

Could you explain more precisely what the issue is here ?

shribe commented 9 years ago

4 entries in pg_stat_statements, 4 entries shown in the web UI

But in the web UI, it looks like some individual entries are sums of the 4 entries in pg_stat_statements, while others are either pulled from a single entry or are an average of the 2 entries for a user id.

I don't care much whether all entries are shown, or they are coalesced into sums/averages as appropriate. But it should be consistent one way or another.

So we have 2 very different values for total times, divided by the same counts, leading to two very different average times. I believe the counts are sums of all 4 while the total times are either one entry or sums of two, so the average times are incorrect. (It's also possible that the total times are from a single arbitrarily chosen row, but however it happens, calculation of total time and counts are inconsistent.)

rjuju commented 9 years ago

Hello,

The last commit (dalibo/powa-web@59515a0386db73f9957ee4b64bebe9321e98bb13) should have fixed this issue.

Could you test to see if everything is ok ?

rjuju commented 9 years ago

Hello,

did you have time to test the provided fix ?

Regards.