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 1uuHNr-006DEq-Mk for pgsql-general@arkaria.postgresql.org; Thu, 04 Sep 2025 21:20:44 +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 1uuHNq-002STi-U0 for pgsql-general@arkaria.postgresql.org; Thu, 04 Sep 2025 21:20:43 +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 1uuHNp-002STX-Se for pgsql-general@lists.postgresql.org; Thu, 04 Sep 2025 21:20:43 +0000 Received: from fout-b1-smtp.messagingengine.com ([202.12.124.144]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uuHNl-000bA3-1v for pgsql-general@lists.postgresql.org; Thu, 04 Sep 2025 21:20:41 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id BA3A41D003A7; Thu, 4 Sep 2025 17:20:35 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Thu, 04 Sep 2025 17:20:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1757020835; x=1757107235; bh=uKZLOsFshBVBz6l5J2BXt1HapQhzAOEUY/ZIm4rxWeQ=; b= 3poGtWrgGdnyp6fxTxnF+qQ5JY1jtysEx+TXAly6UJ+tWJ7dVMYGuIQABSEjBvT3 TNZGjuoNAqOKRxgoO8IVqqG+N0WpOoVTBbBOHMkz0pm3NpxgqHbDtleYPEOiZWpD TNxIhTi0pfffk9kTJaXsA0MM45mVuKFQkiEFRDOPHdKF0Dkjlq7A1HfTIFLWJMyk v5ZNJvpxClYhyNXAB8JEJbvu3pXj9iJ3iBeKz4W4uD+IcUVrFbP/U53lPWGn1rbn hvwmi62AlNzmDPBuPJCs6CjXZAS7C5B4ta1OXDXZxE/DNMIH3vqBfvXdU7MuQeo4 yJYfp8/OYvg0cCWNxJ4PWg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1757020835; x= 1757107235; bh=uKZLOsFshBVBz6l5J2BXt1HapQhzAOEUY/ZIm4rxWeQ=; b=L czWq4ML0QUeA5wTB1DfNGeY7+8oDptX17WNHOGCDnC/cDAlQz9ehpPiAYv+m8ocJ 3KbkQ6S5MD7U+OvpBSYKeNVkELTWodElgpSn9g5eRNuPe9bzHl7uPU0fa3d1OE+g hJmH2FYYXm0FfmBb35V9f7nu7aw91t65S28YUbPqiwc0or8jOY32afFb2CnzviWF 5x/IbRKasXsws37IE8qwG55EtPRw5r3TqRmurExzucRYTTUOmmfW9ZARJ0vVxvZ1 xMQVoLVOoEUjRaFu2jfNx0VFAGQNYI0Qwh9LfJbPs/hcXbY7MjecHPuqa+kFm38j wZ0yyKuxyaN7eSKBlh22w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdejtdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurh epkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeetughrihgrnhcu mfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomheqne cuggftrfgrthhtvghrnhepfeegfeeiuedtgffgteeggfehkeejheetieeliefgteeikeej vdeiveeigfehvedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgspghr tghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepvhgvvghmrgdttd dttdesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhgvghnvghrrghlsehl ihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 4 Sep 2025 17:20:34 -0400 (EDT) Message-ID: Date: Thu, 4 Sep 2025 14:20:34 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Debugging query performance in postgres To: veem v Cc: pgsql-general References: <4794e640-e4a4-4730-985a-57be297122e0@aklaver.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 9/4/25 13:32, veem v wrote: > > On Thu, 4 Sept 2025 at 23:19, Adrian Klaver > We didn't get the exact root cause why the plan flipped but we have to > add additional filters to get rid of the performance issue. Did you do an EXPLAIN ANALYZE before and after the changes? If so did you save the results and can you share them? > The version is 16. > Yes, autovacuum running. > We don't have any major changes. Except for the performance degradation, so something changed. > But if there was a significant change > in quantity of data , Yet to check that. > > The pg_stats_statement does show the execution stats of the individual > query execution , but doesnt show any historical plan deviation. Also > the individual procedure and sql statement are logged into this view but > i was wondering if there is an easy way to relate the sql text of the > procedure with the underlying sqls running within the procedure? The pg_stat_statements view has the following fields(among others): min_exec_time double precision max_exec_time double precision mean_exec_time double precision minmax_stats_since timestamp with time zone I could see a cron job that gathers the above data at regular intervals. Then you could track the query performance at a rough level. -- Adrian Klaver adrian.klaver@aklaver.com