Skip site navigation (1) Skip section navigation (2)

Re: Clearing global statistics

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Greg Smith <greg(at)2ndquadrant(dot)com>
Cc: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Clearing global statistics
Date: 2010-01-14 10:12:18
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
2010/1/12 Greg Smith <greg(at)2ndquadrant(dot)com>:
> Magnus Hagander wrote:
>> I have on my TODO to implement the ability to do stats reset on a
>> single object (say, one table only). Please take this into
>> consideration when you design/name this, so theres no unnecessary
>> overlap :-) Same goes for the stats message itself.
> The idea suggested upthread was to add this:
> pg_stat_reset( which text )
>      which := 'buffers' | 'checkpoints' | 'tables' | 'functions' |  ...
> Now, the way the pg_stat_bgwriter tables are computed, it doesn't actually make sense to separate out clearing the buffers/checkpoints stats, since one of those values is in both categories:  buffers_checkpoint.  They're really all too tightly coupled to break them apart.  So I was thinking of this:
> pg_stat_reset( which text )
>      which := 'bgwriter' | ...
> I could convert the patch I've got to be an initial implementation of this new "pg_stat_reset with a parameter", laying some useful groundwork in the process too.  Then people who want to reset more things can just re-use that same outline and message passing mechanism, just adding comparisons for new text and a handler to go with it--not even touching the catalog again.
> This may not mesh well with what you plan though.  If pg_stat_reset is updated to reset stats on an individual table, that could be a second version that takes in a regclass:
> pg_stat_reset('tablename'::regclass)
> But that seems like a confusing bit of overloading--I can easily see people thinking that pg_stat_reset('bgwriter') would be resetting the stats for a relation named 'bgwriter' rather than what it actually does if I build it that way.
> So, combining with Peter's naming suggestion, I think what I should build is:
> pg_stat_reset_shared( which text )
>      which := 'bgwriter' | ...
> Which satisfies what I'm looking for now, and future patches that need to reset other shared across the cluster statistics can re-use this without needing to add a whole new function/stats message.  I think that satisfies the cross-section of planned use cases we're expecting now best.
> Any comments before I update my patch to do that?

Are you planning to get this in for the CF? (Yes, I realize there are
only hours left). This is functionality I'd *really* like to see in
8.5, so I'll be happy to work with you to get that committed inside or
outside CF bounds, but it's easier if it's on there for reviewers ;)
(plus, the "outside cf bounds" really only works *before* the
commitfest :P)

 Magnus Hagander

In response to

pgsql-hackers by date

Next:From: Dimitri FontaineDate: 2010-01-14 10:19:16
Subject: Re: segmentation fault in function
Previous:From: Magnus HaganderDate: 2010-01-14 10:09:45
Subject: Re: Streaming replication and non-blocking I/O

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group