public inbox for [email protected]  
help / color / mirror / Atom feed
pg_stat_statements_reset
4+ messages / 3 participants
[nested] [flat]

* pg_stat_statements_reset
@ 2024-12-16 15:30 Fabrice Chapuis <[email protected]>
  2024-12-16 15:47 ` Re: pg_stat_statements_reset Tom Lane <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Fabrice Chapuis @ 2024-12-16 15:30 UTC (permalink / raw)
  To: [email protected]

Hi,
This query seems not resetting stats for databae mydb

SELECT pg_stat_statements_reset(
    NULL,  -- userid: NULL means "all users"
    (SELECT oid FROM pg_database WHERE datname = 'mydb'),
    NULL   -- queryid: NULL means "all queries"
);
│ pg_stat_statements_reset │

(1 row)

Something wrong in the use of the function pg_stat_statements_reset?

Regards,

Fabrice


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pg_stat_statements_reset
  2024-12-16 15:30 pg_stat_statements_reset Fabrice Chapuis <[email protected]>
@ 2024-12-16 15:47 ` Tom Lane <[email protected]>
  2024-12-16 15:55   ` Re: pg_stat_statements_reset Guillaume Lelarge <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2024-12-16 15:47 UTC (permalink / raw)
  To: Fabrice Chapuis <[email protected]>; +Cc: [email protected]

Fabrice Chapuis <[email protected]> writes:
> This query seems not resetting stats for databae mydb

> SELECT pg_stat_statements_reset(
>     NULL,  -- userid: NULL means "all users"
>     (SELECT oid FROM pg_database WHERE datname = 'mydb'),
>     NULL   -- queryid: NULL means "all queries"
> );

Where did you get the idea that NULL means "all"?  AFAICS
that function is strict, meaning it won't run at all for
null input.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pg_stat_statements_reset
  2024-12-16 15:30 pg_stat_statements_reset Fabrice Chapuis <[email protected]>
  2024-12-16 15:47 ` Re: pg_stat_statements_reset Tom Lane <[email protected]>
@ 2024-12-16 15:55   ` Guillaume Lelarge <[email protected]>
  2024-12-20 09:43     ` Re: pg_stat_statements_reset Fabrice Chapuis <[email protected]>
  0 siblings, 1 reply; 4+ messages in thread

From: Guillaume Lelarge @ 2024-12-16 15:55 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: Fabrice Chapuis <[email protected]>; [email protected]

Hello,

Le lun. 16 déc. 2024 à 16:47, Tom Lane <[email protected]> a écrit :

> Fabrice Chapuis <[email protected]> writes:
> > This query seems not resetting stats for databae mydb
>
> > SELECT pg_stat_statements_reset(
> >     NULL,  -- userid: NULL means "all users"
> >     (SELECT oid FROM pg_database WHERE datname = 'mydb'),
> >     NULL   -- queryid: NULL means "all queries"
> > );
>
> Where did you get the idea that NULL means "all"?  AFAICS
> that function is strict, meaning it won't run at all for
> null input.
>
>
You should try:

select pg_stat_statements_reset(dbid => oid)
from pg_database
where datname='mydb';

Works on my test case (and I find it easier to understand, but that may be
subjective).


-- 
Guillaume.


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pg_stat_statements_reset
  2024-12-16 15:30 pg_stat_statements_reset Fabrice Chapuis <[email protected]>
  2024-12-16 15:47 ` Re: pg_stat_statements_reset Tom Lane <[email protected]>
  2024-12-16 15:55   ` Re: pg_stat_statements_reset Guillaume Lelarge <[email protected]>
@ 2024-12-20 09:43     ` Fabrice Chapuis <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: Fabrice Chapuis @ 2024-12-20 09:43 UTC (permalink / raw)
  To: Guillaume Lelarge <[email protected]>; +Cc: Tom Lane <[email protected]>; [email protected]

Thanks for your explanations Tom, Guillaume, your solution works fine for
me too.

Regards

Fabrice

On Mon, Dec 16, 2024 at 4:56 PM Guillaume Lelarge <[email protected]>
wrote:

> Hello,
>
> Le lun. 16 déc. 2024 à 16:47, Tom Lane <[email protected]> a écrit :
>
>> Fabrice Chapuis <[email protected]> writes:
>> > This query seems not resetting stats for databae mydb
>>
>> > SELECT pg_stat_statements_reset(
>> >     NULL,  -- userid: NULL means "all users"
>> >     (SELECT oid FROM pg_database WHERE datname = 'mydb'),
>> >     NULL   -- queryid: NULL means "all queries"
>> > );
>>
>> Where did you get the idea that NULL means "all"?  AFAICS
>> that function is strict, meaning it won't run at all for
>> null input.
>>
>>
> You should try:
>
> select pg_stat_statements_reset(dbid => oid)
> from pg_database
> where datname='mydb';
>
> Works on my test case (and I find it easier to understand, but that may be
> subjective).
>
>
> --
> Guillaume.
>


^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2024-12-20 09:43 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-12-16 15:30 pg_stat_statements_reset Fabrice Chapuis <[email protected]>
2024-12-16 15:47 ` Tom Lane <[email protected]>
2024-12-16 15:55   ` Guillaume Lelarge <[email protected]>
2024-12-20 09:43     ` Fabrice Chapuis <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox