Re: New function pg_stat_statements_reset_query() to reset statistics of a specific query
Haribabu Kommi <kommi.haribabu@gmail.com>
From: Haribabu Kommi <kommi.haribabu@gmail.com>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>,
Michael Paquier <michael@paquier.xyz>, Amit Kapila <amit.kapila16@gmail.com>, Magnus Hagander <magnus@hagander.net>,
sk@zsrv.org, Robert Haas <robertmhaas@gmail.com>, Fujii Masao <masao.fujii@gmail.com>, Ashutosh Sharma <ashu.coek88@gmail.com>,
Euler Taveira <euler@timbira.com.br>, Pg Hackers <pgsql-hackers@postgresql.org>,
Simon Riggs <simon@2ndquadrant.com>, Dave Page <dpage@pgadmin.org>
Date: 2018-11-22T23:09:47Z
Lists: pgsql-hackers
On Fri, Nov 23, 2018 at 1:54 AM Peter Eisentraut < peter.eisentraut@2ndquadrant.com> wrote: > On 19/11/2018 06:18, Haribabu Kommi wrote: > > Amit suggested another option in another mail, so total viable > > solutions that are discussed as of now are, > > > > 1. Single API with NULL input treat as invalid value > > 2. Multiple API to deal with NULL input of other values > > 3. Single API with NULL value to treat them as current user, current > > database > > and NULL queryid. > > 4. Single API with -1 as invalid value, treat NULL as no matching. (Only > > problem > > with this approach is till now -1 is also a valid queryid, but setting > > -1 as queryid > > needs to be avoided. > > Can you show examples of what these would look like? > Following are some of the examples how the various options work. Option -1: select pg_stat_statements_reset(NULL,NULL,NULL); -- No change, just return. Because the function is strict. select pg_stat_statements_reset(10,10,NULL); -- Resets all the statements that are executed by userid 10 on database id 10. select pg_stat_statements_reset(NULL,10,NULL); -- Resets all the statements executed on database id 10 Option - 2: select pg_stat_statements_reset(NULL,NULL,NULL); -- No change, just return. Function are of type strict. select pg_stat_statements_reset(10,10,1234) -- Resets the query statement 1234 executed by userid 10 on database id 10 select pg_stat_statements_reset_by_userid(10) -- Resets all the statements executed by userid 10 select pg_stat_statements_reset_by_dbid(10); -- Rests all the statements executed on database id 10. select pg_stat_statements_reset_by_userid_and_dbid(10, 10); -- Resets all the statements executed by userid 10 on datbase id 10 Likewise total 7 API's. Option -3: select pg_stat_statements_reset(NULL,NULL,NULL); --Similar like option-1, but when the userid or databaseid are NULL, it uses the current_role and current_database as the options. But for the queryid when the options is NULL, it deletes all the queries. Rest of the details are same as option-1. Option -4: select pg_stat_statements_reset(NULL,NULL,NULL); -- No change, just return. Because the function is strict. select pg_stat_statements_reset(0,0,0); -- Resets all the statements select pg_stat_statements_reset(0,10,0); -- Resets all the statements executed on database id 10 select pg_stat_statements_reset(10,0,0); -- Resets all the statements executed on userid 10. Regards, Haribabu Kommi Fujitsu Australia
Commits
-
Extend pg_stat_statements_reset to reset statistics specific to a
- 43cbedab8ff1 12.0 landed
-
Default monitoring roles
- 25fff40798fc 10.0 cited