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 1sxniJ-00CUws-29 for pgsql-general@arkaria.postgresql.org; Mon, 07 Oct 2024 13:23:51 +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 1sxniG-00AuBN-Su for pgsql-general@arkaria.postgresql.org; Mon, 07 Oct 2024 13:23:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sxniG-00AuBF-HO for pgsql-general@lists.postgresql.org; Mon, 07 Oct 2024 13:23:48 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sxniD-002xRf-VI for pgsql-general@lists.postgresql.org; Mon, 07 Oct 2024 13:23:47 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-53991d05416so5088678e87.2 for ; Mon, 07 Oct 2024 06:23:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728307424; x=1728912224; 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=dkSoKAFJLEpN47+2LT8LsWyziPipekrPl/XmqReCqHM=; b=dq+ZQS0hfIOY9jZeLwkMj6qKTV5rTd74TRTVRxBobTdUd3Mqg9JXbOiWYQcl7+/1WZ /0VM7aAHFJAfftzQEkHF85U6EzYzjUD5ar/KjTzDSxih2scaJMa6XeLTbd3onzx8RJJu CZeGemniiSrPV1MPVJVbNqo/k8NwQxw+rIxGUWzguNmDCNH7oZ//fRLKcWsU6R7hqR13 lK1cZlCsd8Ou+EbOBl2g0smyJG7yqtNoE+UZqlnfxmzy+MkbmlYF2S3VkNC6qK730uQV zukLpw5GT93fOk4nTXlDK4jLCJni4mxE0GH+vftyApfHNbIRcKQdOMsMGCRQk3q+5AUV Rmug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728307424; x=1728912224; 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=dkSoKAFJLEpN47+2LT8LsWyziPipekrPl/XmqReCqHM=; b=FA7QYJ6Zc7FpJIlTu5GRd8OkqV5NDH/i0PT7S+jdkMBE2kXaE90sxaVZobSXnRJXxh OR4MQV0RcMVMfzw3wPc4STHIvEc2aRIHvKVfr+Ga3dPC8Va0mgGEQyXx0cGJ8I0TtpNB Zc9wrMdBCYp+QQj3QjsV8A6ibS5LFOuB+S9W8BWn8Nv1bOoGBw14NIe3gz0Tx9vtcQdR VMjjGpwcAnrcB9FMnJh5z7e9es50QACocziBqqLNko+kKzKQNsmn86Gz2Fc2Vvypzfq+ l5iAs8oH2TthoVkAKYL8MXNUvp8mgGjWlb5rTotNYRjhXzdYZfJyhYQDik1FwNqY9eBg OtLw== X-Forwarded-Encrypted: i=1; AJvYcCUFPoXuTKL+0xxQiynp9egMOuhTVsW3RfICMzQptDTGFhPNZN859NhmmZK4UQVrDFwaL4znVNAVGkBJDUvD@lists.postgresql.org X-Gm-Message-State: AOJu0YyaQfn5aJCzEqdymjz/+KMo4XwgKoyP/N2pTKkx1fae79peUiJu 6P085F/eT6zf7fwDfBgEZ3tL3xRrvM8362h88rxq7TxsNxU0vfoIWK9F2s19L2VyvlIa+sKFP9X Bxki+R+GMxnmgxk7Dl6lbJh89jFY= X-Google-Smtp-Source: AGHT+IFVUDpMkAwL6EfA/xKQUt098FOMe/GPK7BtB5Jmf+yKCaz0GXPtnkffasoOLasfX/0wO06V30QsZjmI0jpz7oQ= X-Received: by 2002:a05:6512:68a:b0:539:8d2c:c01a with SMTP id 2adb3069b0e04-539ab87daf5mr8755857e87.29.1728307423948; Mon, 07 Oct 2024 06:23:43 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Greg Sabino Mullane Date: Mon, 7 Oct 2024 09:23:08 -0400 Message-ID: Subject: Re: Question on pg_stat* views To: Adrian Klaver Cc: veem v , pgsql-general Content-Type: multipart/alternative; boundary="000000000000113c050623e2ee8c" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000113c050623e2ee8c Content-Type: text/plain; charset="UTF-8" Adrian and Veem were saying: > > so does it mean that we should increase the pg_stat_statement.max to > further higher value? > Yes, you should raise this setting if you find your queries are getting pushed out. Moving to version 17 will also help, as myself and others have been working on normalizing more queries, which means less overall entries in pg_stat_statements, and more room before hitting pg_stat_statements.max. But bump it to 10000 for now. Now what I don't know is if pg_stat_statement exhibits the same behavior > as the core statistics and resets on an unclean shutdown. > It does - pg_stat_statements will be emptied out if Postgres restarts after a crash. > 3)As pg_stat_statements holds the aggregated stats of all the execution > > for a particular sql query ,so it's not easy to identify if in the past > > at some point in time the same query suffered and thus went for high > > response time. So to debug such performance issues scenarios , is it > > advisable to insert the records from this pg_stat* views to another > > table manually periodically through a cron job? > Typically, you use pg_stat_statements in conjunction with a good log_min_duration_statements setting to allow you to see specific slow queries as well as the aggregated info. It's also a good idea to rotate things via cron, as you mention. Cheers, Greg --000000000000113c050623e2ee8c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Adrian and Veem=C2=A0were saying:
=C2=A0> s= o does it mean that we should increase the pg_stat_statement.max to further= higher value?

Yes, you should raise th= is setting if you find your queries are getting pushed out. Moving to versi= on 17 will also help, as myself and others have been working on normalizing= more queries, which means less overall entries in pg_stat_statements, and = more room before hitting pg_stat_statements.max. But bump it to 10000 for n= ow.

Now what I don't know is if pg_stat_statement exhibits the same behavio= r
as the core statistics and resets on an unclean shutdown.
<= div>
It does - pg_stat_statements will be emptied out if Post= gres restarts after a crash.

> 3)As pg_stat_statements holds the aggregated s= tats of all the execution
> for a particular sql query ,so it's not easy to identify if in the= past
> at some point in time the same query suffered and thus went for high <= br> > response time. So to=C2=A0debug such performance=C2=A0 issues scenario= s , is it
> advisable to insert the records from this pg_stat* views to another > table manually periodically through a cron job?
<= br>
Typically, you use pg_stat_statements in conjunction with a g= ood log_min_duration_statements setting to allow you to see specific slow q= ueries as well as the aggregated info. It's also a good idea to rotate = things via cron, as you mention.

Cheers,
Greg

--000000000000113c050623e2ee8c--