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 1sxWfT-00AeCb-7a for pgsql-general@arkaria.postgresql.org; Sun, 06 Oct 2024 19:11:47 +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 1sxWfQ-000fIx-Pm for pgsql-general@arkaria.postgresql.org; Sun, 06 Oct 2024 19:11:44 +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 1sxWfQ-000fHB-Co for pgsql-general@lists.postgresql.org; Sun, 06 Oct 2024 19:11:44 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sxWfJ-002pj9-Qs for pgsql-general@lists.postgresql.org; Sun, 06 Oct 2024 19:11:43 +0000 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5c718bb04a3so5122095a12.3 for ; Sun, 06 Oct 2024 12:11:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728241896; x=1728846696; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=WNhtarc0QX939qW6bl0/A/4a2SgmqEsZUouH2NKDeLM=; b=eSOLsKUp5KdalmhJ3LcOqoFCU56DThNUshuR6TfcHPINLbqW1HD4o6TAlBNs3v1iUC B735+zbilsutsfGn4Z9XL+n9aQ5vPXqIvEZ6zNjCoBDfiQ7RWZVAzOimB69YJNreh5VE t603p++l1iBmjcXf1IohD2gkF7wMM4Zz/fJGUFiUqe3fV0R6Rw8uuxpHoXXExYxrqzf3 trw58einCGgHM1DPVCKsNMvWwPCXUUYuc8EHYlUCoJ/e/fbkKfF9uGsmVyBy6ErZQEcD 260OS17UppaOqskBUyjhsVI0R6s8XRgp8ThOVgWeGVulwv/8EtyhbMHZj2teYPnuusBj zs0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728241896; x=1728846696; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=WNhtarc0QX939qW6bl0/A/4a2SgmqEsZUouH2NKDeLM=; b=W9S0+hAwdOO4l4I96FkPUudBROtYZT3HfbCCJ5Pg5+Ac0cLtq1vpBg0F438DeIpupu 20n+nrkxfzEUU1ytoFhoTTjfr2P96KNE2Maa4lQeN9KmFlth89Jv4OvqiCVBAn5EPMe1 bJJOVyB8BkXuxh60FWGb4WnHDd6zVidZgjmSEZWRtbtJ574uyzWJGK4Y5BRb/0vwSt2c ND+XRlRKBgUWwgwPlfCFmJqFm1DNaXVSTgyk37cfMcURY2+O8oEGoQQrumcGEkkmQQC0 QHhhT8ffBtdt8a9nnbtDIm0MjQOuYuEtEU5ZxY8O/X278GhGPR/PRWqmJWoIEbZItxvQ VoYQ== X-Gm-Message-State: AOJu0YwomIvhGuDDubQ9B2UBXGZkVZ1xUchfngf/q07hBX8rMtV6ZItY OafwaNjDgoItvS0O9oSGowYUKsY8IaVJxrYKJTlnIUfE4pWRRSEF3k3YepFOHe9Z1MJRa8epG+I Q4vZjwsaOZYfDO579RFPRy76KFHdjJUgu X-Google-Smtp-Source: AGHT+IGX+MpC+BomIDtpKD/u8kTr1gsVvcffkfZaRVAu4G0cTtIezoSghxr6oEZIpB8cTdHSzqvFDz/xbggCzT/DhK8= X-Received: by 2002:a17:907:d14:b0:a99:4ca4:4fd8 with SMTP id a640c23a62f3a-a994ca451a1mr376032666b.41.1728241895938; Sun, 06 Oct 2024 12:11:35 -0700 (PDT) MIME-Version: 1.0 From: veem v Date: Mon, 7 Oct 2024 00:41:24 +0530 Message-ID: Subject: Question on pg_stat* views To: pgsql-general Content-Type: multipart/alternative; boundary="0000000000004b26030623d3ac6a" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000004b26030623d3ac6a Content-Type: text/plain; charset="UTF-8" Hi, As per my understanding , the pg_stat_statements stores the aggregated statistics of the query execution history(with almost near real time executions) and the max number of statements or queries it can store depends on the pg_stat_statement.max value(which I am seeing as ~5000 in pg_settings). I have below questions, 1)Doing a count(*) on pg_stat_statements giving ~4818. But still pg_stat_statements_info showing ~1990 as "dealloc" which means there are more sql queries coming up and they are getting flushed out of the pg_stat_statements, so does it mean that we should increase the pg_stat_statement.max to further higher value? 2)The stats_reset column in pg_stat_statements_info view is showing as 16th august , so does it mean that, whatever query stats are getting logged in the pg_stat_statements, those are the aggregated stats for all the executions that have happened since the day 16th august till today? Also as we have not done any "stats reset" manually , so does it happen automatically when the DB instance restarts or with any other database events? 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? Regards Veem --0000000000004b26030623d3ac6a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,
As per my understanding , the pg_stat_statements s= tores the aggregated statistics of the query execution history(with almost = near real time executions) and the max number of statements or queries it c= an store depends on the pg_stat_statement.max value(which I am seeing as ~5= 000 in pg_settings). I have below questions,

1)Doing a count(*) on p= g_stat_statements giving ~4818. But still pg_stat_statements_info showing ~= 1990 as "dealloc" which means there are more sql queries coming u= p and they are getting flushed out of the pg_stat_statements, so does it me= an that we should increase the pg_stat_statement.max to further higher valu= e?

2)The stats_reset column in pg_stat_statements_info view is showi= ng as 16th august , so does it mean that, whatever query stats are getting = logged in the pg_stat_statements, those are the aggregated stats for all th= e executions that have happened since the day 16th august till today? Also = as we have not done any "stats reset" manually , so does it happe= n automatically when the DB instance restarts or with any other database ev= ents?

3)As pg_stat_statements holds the aggregated stats of a= ll the execution for a particular sql query ,so it's not easy to identi= fy if in the past at some point in time the same query suffered and thus we= nt for high response time. So to=C2=A0debug such performance=C2=A0 issues s= cenarios , is it advisable to insert the records from this pg_stat* views t= o another table manually periodically through a cron job?

Regards
Veem
--0000000000004b26030623d3ac6a--