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 1uuE5M-0057X5-Gf for pgsql-general@arkaria.postgresql.org; Thu, 04 Sep 2025 17:49:25 +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 1uuE5L-001AFV-LJ for pgsql-general@arkaria.postgresql.org; Thu, 04 Sep 2025 17:49:24 +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 1uuE5K-001ADN-LK for pgsql-general@lists.postgresql.org; Thu, 04 Sep 2025 17:49:23 +0000 Received: from fhigh-b2-smtp.messagingengine.com ([202.12.124.153]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1uuE5J-000Xoe-0a for pgsql-general@lists.postgresql.org; Thu, 04 Sep 2025 17:49:22 +0000 Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfhigh.stl.internal (Postfix) with ESMTP id B60C27A0412; Thu, 4 Sep 2025 13:49:19 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Thu, 04 Sep 2025 13:49:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= 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=1757008159; x=1757094559; bh=5N1p2k9/zFcIfbh1LlG/HLWPJ+ukPg/c8DiqzQ8M+8U=; b= 3NeG1uj8jrLC34fN066LlGbQCsYwk6o9qEaV1IYin7323qeN67Ud/TYlw41X4O6i rTALr7qmTUn3aSKyGVAXpmJdQ5No4QzjXhgkrKHc0H+fUWbbEwkhut32uJ7KQwDC 1VAlvnnpuHMOdUrQ/cZ4CdRTUBh5MFAjDeNvCBwb3BnBp5WCAz2DVidqK4vreb9I Umv1cGF6wZUDFKlo3/gURS9poKBGtJqdtI9BjE1VdaxU2UnSYnQN005s6rQ5Bvgn lOk2qZqhiI17sCoyFxcMCTRKw9+LPxbyzpdINz6gHk/Un82HucpiHZaDjbarFOAD Ba0nXCfMtroY60mfRehFAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=1757008159; x=1757094559; bh=5 N1p2k9/zFcIfbh1LlG/HLWPJ+ukPg/c8DiqzQ8M+8U=; b=iX025dGVVTplFu13r b6fnVSjcNiDU/ssvDKU2agStvAs0oIONLvs/2nbiwC2EAEHTpwLnsooplq0XMNDm mAFhew8osKj5td+4qAWyrIyQJ4diNoD2GPtMD4Lb/0Mt9N8CKtYzPjuK4xa9sVNh Ad+msS3Pd7Et4uCDmtsPrwT7n12ebzOUpFSF8jwcEoAPS+iPmJRyW/mE/H//cINa 5PxmxImCwfm0c2RV6AgK2F+EugdileSUC4bQYoBv1qEuoKYBv1OFqlSen+ornpba CCaYzKxgYdd00ttD3dpkZswUuDrFse85gy25tOXqb1dOYSgJJWKaPfD0HwGRs7H3 2t3AQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdeiieeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurh epkfffgggfuffvfhfhjggtgfesthejredttddvjeenucfhrhhomheptegurhhirghnucfm lhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenuc ggtffrrghtthgvrhhnpeekfeehuddvjeeigfeifeejtdduudffledvfeelheeftdeiffeu gfdvkeelgedtvdenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgspghrtghpthhtohepvddpmhhouggvpe hsmhhtphhouhhtpdhrtghpthhtohepvhgvvghmrgdttddttdesghhmrghilhdrtghomhdp rhgtphhtthhopehpghhsqhhlqdhgvghnvghrrghlsehlihhsthhsrdhpohhsthhgrhgvsh hqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 4 Sep 2025 13:49:18 -0400 (EDT) Message-ID: <4794e640-e4a4-4730-985a-57be297122e0@aklaver.com> Date: Thu, 4 Sep 2025 10:49:18 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Debugging query performance in postgres To: veem v , pgsql-general References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 9/4/25 09:57, veem v wrote: > Hello, > We have a situation in which we had a dml query within a procedure that > was running fine but suddenly the plan flipped and it started running > longer. It took us a good amount of time to identify the cause and fix > it. So I have below questions, What was the cause? Postgres version Was there any major changes in the database e.g schema changes or quantity of data? Is autovacuum running? > 1)Do we have any data dictionary view or query available which gives us > information on what were the queryids those are executing from within a > procedure and how much time they are taking? > 2)Also how to identify , if any specific queries has opted a different > plan today as compared to past executions and also response time > increased because of that? Take a look at: https://www.postgresql.org/docs/current/pgstatstatements.html > > Regards > Veem -- Adrian Klaver adrian.klaver@aklaver.com