Mot-clé - PostgreSQL 9.0

Fil des billets - Fil des commentaires

lundi, juillet 26 2010

Reset statistics for one table or one function

During 9.0 development, Magnus Hagander added two system functions to reset an object's statistics. The first one, pg_stat_reset_single_table_counters(), to reset a statistics of a specific relation, the second one, pg_stat_reset_single_function_counters(), to reset a function's statistics. I don't know why but it fell off my radar for some reason during the development of pgAdmin 1.11.

So, now that we can start adding new features to pgAdmin, I worked on a patch to use these two system functions.

Say you have a table named t1. It has some statistics. You can see them on the Statistics tab of the browser window:

ticket186_1.png

You want to reset its statistics. Right-click on the table's name in the brower, select "Reset statistics":

ticket186_2.png

pgAdmin will ask you to confirm the action:

ticket186_3.png

And, if you answered yes, pgAdmin will fire the "SELECT pg_stat_reset_single_table_counters(<oid of the table>)" query, and display the new counters:

ticket186_4.png

You probably noticed it didn't reset all counters. That's right. Index counters need to be reset separately. That's something missing on my patch. Something I should fix ASAP.