Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tOZXk-007FyB-8e for pgsql-admin@arkaria.postgresql.org; Fri, 20 Dec 2024 09:43:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tOZXj-008DVM-Hk for pgsql-admin@arkaria.postgresql.org; Fri, 20 Dec 2024 09:43:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tOZXj-008DVE-67 for pgsql-admin@lists.postgresql.org; Fri, 20 Dec 2024 09:43:34 +0000 Received: from mail-oa1-x32.google.com ([2001:4860:4864:20::32]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tOZXg-000jR7-7b for pgsql-admin@lists.postgresql.org; Fri, 20 Dec 2024 09:43:34 +0000 Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-2a01aaba93eso63799fac.0 for ; Fri, 20 Dec 2024 01:43:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734687810; x=1735292610; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=cuzb/N/c6UJSSedA9wBTuKvQUacAofF21m6omPBOttA=; b=hvZSwPquMgZpspqQNG3CDCiCtWdfaD+W19MMwu9tFZaXz0foFUOL301CSJq+Rt97o7 jVcDUZQRlnWNz9WZA5AzAQ8rK8wuI3y4mulcODUv+wkUYM0iw1Q/QrE1b5zIULDK/UsU FtC2K/LmSTHbnE60nDolfRmtoXzwlqVaj1cBySPQoYrKkhpxZ+ckBp5rAmkJ4cOYwa98 3CmLyiLosIY6Oz3onryh3pKCMW3+UTaVfrqBoroSYWrg2DqHh8xA1/KyOQrbhN0m27XU Ov8cgqlHtZGJTy/y3ZkHvTODdrMQyLNlHfnB90LG/EjWttdeHNHM459eFwQGUDrQnrGr hung== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734687810; x=1735292610; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cuzb/N/c6UJSSedA9wBTuKvQUacAofF21m6omPBOttA=; b=KXUWY2Hb8mfoBXc//W07xToktnSbfs/nAU+rOMPQCPUhzi3v3vlNiGBHiKv2btKerw Uh/d6ar5TKYFgMDrmAcfoZGacZr9IGRaqoYnGynOtf16W4WbT0yzBgzSIgK8sBxkF7dR HogkCF3SNWS67pusF0zJ0yl+CmZKYNwnofiiucnVUEg6VlUMb4AqY7wOlltoro5htgcG j8kTrNz7n7ANaPTVYjdjZVQQfK2JWyDmUDLEZFI+fW/AneeKG2uQ7/wbFB1oLbZMZ0qf RjxG6G1vJRxiez3jXE80jXzIIlMEcw/U7WzS5hw9bL8Ux+TyBwqsOcDk5MLJYdEwsXmj 2Bbg== X-Forwarded-Encrypted: i=1; AJvYcCWGM7AGWqaA2ldx6VY991ozWDU58dz6tGgB7unkrcNuRhTd0MV12LW9YG+0/ATSCNbtwhacM3ByIUTt+Q==@lists.postgresql.org X-Gm-Message-State: AOJu0Yx2YVA+7cr+eeDH92BVmwaD2qbu/rXgKmh/szjkJ/CD7bcucOiO TP0keTcTGMRjMqPfzHOjeGpPMqB3dMU+7PPbEQGXnnVlWffOQ7Thg2vI6swGbB89cwHVlLnxnEn SNHmoInEShrNPLWa7MJ2yih0Dwm3mjg== X-Gm-Gg: ASbGncuZniqQE2mU7KCdVfD8/gWaQ79vs6wdD6DyCZiuT1wsTc23UNnSV9tIhThj297 g2+jggHzsZi7NxqQFr3rU0Awsz4qTjspaSeTc X-Google-Smtp-Source: AGHT+IFKeFd7N9J0cAR25ZEMCBp4+DJRg+ZLoEmee3kuHwohTIMjetfe/pTCWrOAmKEP2QGLRiiUsZJzLXuNod8/nhU= X-Received: by 2002:a05:6870:ff83:b0:29e:79ce:933a with SMTP id 586e51a60fabf-2a7fb392050mr463664fac.12.1734687810225; Fri, 20 Dec 2024 01:43:30 -0800 (PST) MIME-Version: 1.0 References: <1976972.1734364021@sss.pgh.pa.us> In-Reply-To: From: Fabrice Chapuis Date: Fri, 20 Dec 2024 10:43:19 +0100 Message-ID: Subject: Re: pg_stat_statements_reset To: Guillaume Lelarge Cc: Tom Lane , pgsql-admin@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000b999590629b07aae" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000b999590629b07aae Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks for your explanations Tom, Guillaume, your solution works fine for me too. Regards Fabrice On Mon, Dec 16, 2024 at 4:56=E2=80=AFPM Guillaume Lelarge wrote: > Hello, > > Le lun. 16 d=C3=A9c. 2024 =C3=A0 16:47, Tom Lane a = =C3=A9crit : > >> Fabrice Chapuis 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 =3D '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 =3D> oid) > from pg_database > where datname=3D'mydb'; > > Works on my test case (and I find it easier to understand, but that may b= e > subjective). > > > -- > Guillaume. > --000000000000b999590629b07aae Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks for your explanations Tom, Guillaume, your solution= works fine for me too.

Regards

Fabrice

On Mon, Dec 16, 2024 at 4:56=E2=80=AFPM= Guillaume Lelarge <guillaume@= lelarge.info> wrote:
Hello,

Le=C2=A0lun. 16 d= =C3=A9c. 2024 =C3=A0=C2=A016:47, Tom Lane <tgl@sss.pgh.pa.us> a =C3=A9crit=C2=A0:
=
Fabrice Chapuis <= ;fabrice636861= @gmail.com> writes:
> This query seems not resetting stats for databae mydb

> SELECT pg_stat_statements_reset(
>=C2=A0 =C2=A0 =C2=A0NULL,=C2=A0 -- userid: NULL means "all users&q= uot;
>=C2=A0 =C2=A0 =C2=A0(SELECT oid FROM pg_database WHERE datname =3D '= ;mydb'),
>=C2=A0 =C2=A0 =C2=A0NULL=C2=A0 =C2=A0-- queryid: NULL means "all q= ueries"
> );

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


You should try:

select pg_stat_statements_reset(dbid =3D> oid)
from pg_data= base
where datname=3D'mydb';

Wor= ks on my test case (and I find it easier to understand, but that may be sub= jective).


--
Guillaume.
--000000000000b999590629b07aae--