zubkov-andrei / pg_profile

Postgres historic workload reports
Other
228 stars 33 forks source link

Incorrect figures in report on database before first reset #62

Closed portnov closed 1 year ago

portnov commented 1 year ago

Some figures in report are incorrect if you take snapshots on a database, on which pg_stat_reset was never called (it was created not so long ago). For example, in the very first section, "database statistics", the report shows "database growth" equal to "database size", as if the database would be created within report interval; but was not. Similarly, "Top tables by..." sections include tables which were not used within report interval. I tried to investigate this, and found constructions like https://github.com/zubkov-andrei/pg_profile/blob/master/sample/sample.sql#L601-L602 here, if stats were never reset, both lst.stats_reset and cur.stats_reset are null. But null is not equal to null! So the query behaves like there is no "previous" snapshot. As far as I see, similar construction is used in many places. Theoretically this should be easy to fix by replacing "=" with "is not distinct from".

Steps to reproduce:

Temporary solution: call at least pg_stat_reset before taking the first snapshot. It may appear that there are similar problems in similar places, so it is required to reset something else in order to get correct figures, I'm not sure.

zubkov-andrei commented 1 year ago

Hi! Yes, I know about this bug. As I can see it is appering only in Postgres 15. This bug is already fixed and some optimizations is done afterwards. I just didn't release it yet. Release is quite complicated process, so I want to test some more features before. Anyway next release will be free of this bug.

zubkov-andrei commented 1 year ago

Fixed in 4.2