Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 624461337BD7 for ; Sat, 11 Dec 2010 12:19:27 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 16995-06 for ; Sat, 11 Dec 2010 16:19:20 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from elizabeth.gransy.com (elizabeth.gransy.com [89.187.132.199]) by mail.postgresql.org (Postfix) with ESMTP id 00E321337BD0 for ; Sat, 11 Dec 2010 12:19:14 -0400 (AST) Received: from sq.gransy.com (localhost [127.0.0.1]) by elizabeth.gransy.com (Postfix) with ESMTP id AA58B15E40F7 for ; Sat, 11 Dec 2010 17:19:11 +0100 (CET) Received: from 94.112.1.61 (SquirrelMail authenticated user tv@fuzzy.cz) by sq.gransy.com with HTTP; Sat, 11 Dec 2010 17:19:11 +0100 Message-ID: <4e19b0bfc836f7002752517e7792a0b9.squirrel@sq.gransy.com> Date: Sat, 11 Dec 2010 17:19:11 +0100 Subject: not all pg_stat_database fields reset after pg_stat_reset() From: tv@fuzzy.cz To: pgsql-bugs@postgresql.org User-Agent: SquirrelMail/1.4.21 MIME-Version: 1.0 Content-Type: multipart/mixed;boundary="----=_20101211171911_26285" X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201012/73 X-Sequence-Number: 28879 ------=_20101211171911_26285 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit After calling pg_stat_reset, some of the database stats fields are not actually reset, the value is preserved. I've found the bug is actually in pgstat_recv_resetcounter function, where only some of the PgStat_StatDBEntry fields are reset to 0. This is true for those 6 fields: n_tuples_returned n_tuples_fetched n_tuples_inserted n_tuples_updated n_tuples_deleted last_autovac_time The docs for "pg_stat_reset()" say "Reset all statistics counters for the current database to zero (requiret superuser privileges)" and I don't see any reason why these fields should not be reset, so I guess it's a bug. See the patch attached (against current dev version). regards Tomas ------=_20101211171911_26285 Content-Type: text/plain; name="missing-fields.diff" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="missing-fields.diff" diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index c3c136a..6510831 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -4010,6 +4010,14 @@ pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len) dbentry->n_xact_rollback = 0; dbentry->n_blocks_fetched = 0; dbentry->n_blocks_hit = 0; + + dbentry->n_tuples_returned = 0; + dbentry->n_tuples_fetched = 0; + dbentry->n_tuples_inserted = 0; + dbentry->n_tuples_updated = 0; + dbentry->n_tuples_deleted = 0; + + dbentry->last_autovac_time = 0; memset(&hash_ctl, 0, sizeof(hash_ctl)); hash_ctl.keysize = sizeof(Oid); ------=_20101211171911_26285--