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 1tNDS9-009NGw-D0 for pgsql-admin@arkaria.postgresql.org; Mon, 16 Dec 2024 15:56:13 +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 1tNDS6-008LdF-Tk for pgsql-admin@arkaria.postgresql.org; Mon, 16 Dec 2024 15:56:12 +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 1tNDS6-008Ld6-C6 for pgsql-admin@lists.postgresql.org; Mon, 16 Dec 2024 15:56:11 +0000 Received: from mail-yb1-xb32.google.com ([2607:f8b0:4864:20::b32]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tNDS2-003ATy-Sv for pgsql-admin@lists.postgresql.org; Mon, 16 Dec 2024 15:56:10 +0000 Received: by mail-yb1-xb32.google.com with SMTP id 3f1490d57ef6-e3983f8ff40so2517380276.1 for ; Mon, 16 Dec 2024 07:56:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lelarge-info.20230601.gappssmtp.com; s=20230601; t=1734364565; x=1734969365; 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=X5tMj37cT4ifcHZJ+YdIQpiVlYiu83suFWPHUQSCn0g=; b=aPmprQsEknJSvnwdWOUPsiM+FTETVwOu/kuBNLgkmvUKFsChtJmHK+Qx9otMfBu/KB bd6Q+adNY3ma7qboxL39vgd/0ch7CeU5Fy9jdjY9V0DwuGSG4q9cLrY9AlG/MAEjqGJw I8rlinY00WJY5mMdcEZu2s7SBuMQbdN7fylan05wlCLpz4QiuMPFwD87jQoLNma07ZXF P6sbM5x4RHvsfwHfD3Rn/jkp4raNN/cqhymt2d16tH0eRc0mMS7nqHeMlCIn0EGA9A2f n+x6FmPmSTAillUiP5pRU4vkjowl0LBaiXzzzJ351gCsOIFBmKkwQ/smWyl+oilExC39 FG/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734364565; x=1734969365; 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=X5tMj37cT4ifcHZJ+YdIQpiVlYiu83suFWPHUQSCn0g=; b=ajc9/GXb0F2lfrhFx3CEHP88NPKrcTBrOybKYFGHCpSIBSoZa+0ybbRkoahBWBlyi+ /AgUSl4Uz9CmylXe3Y0iMfeV3dWn68U639PPKnEqUNQU/T5Ff9xblRpECHzUJJoIGchV XzySqvwNuVlSgy0jVdgYb5XdF5m8Xe9fwVJ1IqWotwCMAgsAzJUGae+AovF0DWO/5hZB EQ67JTRl4CQwZiY5pGq4qnbFtSNuVhVCNIpN2AA0XuAKTu3oqf/UbeM727HDYOp0T0HM G2yqaxw0hkSoNNXVtx+M4Gbw7gNfc6uy6BMekx5S/TQobEJE90u19DcOubktAf+rQm5z XejA== X-Forwarded-Encrypted: i=1; AJvYcCVygYHSalvEDPNfW51J6qQVBCdFLd4kcun7fZuErm4CEQSVzU+REqbIbsDHj7PrJfBX0mZe3TFe5kI0Aw==@lists.postgresql.org X-Gm-Message-State: AOJu0YxM1GqJxJqV7UBttvZqBCInCDTljtXcTLdmdiIATvXnTJNoyHQ8 iiBsL+/vJDrTtQkXt0ilUdmE2r/oyXpnByWAYqJdIV02sjiwxgKmZh5sfo2k056QB7wJO4AgR0r 0zNTcfG9uJk5hjrFYBnVoN/fHNEGDWnxlSX3UWw== X-Gm-Gg: ASbGnct6G/tv1RA9YL/qnpPZA5JEczR56/QRf9vvBwp0tzC1n82PufCbi4/2JyM+5Eh twJXFK5Pg5df1VoYQHvWN5MDWMLoN8+VcYUATufw= X-Google-Smtp-Source: AGHT+IGuYSszDyjUh7qe7c9uS/a8NAcJTmxR08JjkksRpbuKcJIy2NgsbMC6FaLDmkCM1PDZ0Lp1ajj3H8E40bimMX0= X-Received: by 2002:a05:6902:2292:b0:e4f:45d:2d with SMTP id 3f1490d57ef6-e4f045d02f2mr2312998276.8.1734364564853; Mon, 16 Dec 2024 07:56:04 -0800 (PST) MIME-Version: 1.0 References: <1976972.1734364021@sss.pgh.pa.us> In-Reply-To: <1976972.1734364021@sss.pgh.pa.us> From: Guillaume Lelarge Date: Mon, 16 Dec 2024 16:55:54 +0100 Message-ID: Subject: Re: pg_stat_statements_reset To: Tom Lane Cc: Fabrice Chapuis , pgsql-admin@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000ccadc40629653706" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000ccadc40629653706 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 be subjective). --=20 Guillaume. --000000000000ccadc40629653706 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,

Le=C2=A0l= un. 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.c= om> 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.
--000000000000ccadc40629653706--