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 1rnj9C-00EkLa-SE for pgsql-sql@arkaria.postgresql.org; Fri, 22 Mar 2024 17:57:43 +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 1rnj9B-006KAe-5W for pgsql-sql@arkaria.postgresql.org; Fri, 22 Mar 2024 17:57:41 +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 1rnj9A-006KAK-T2 for pgsql-sql@lists.postgresql.org; Fri, 22 Mar 2024 17:57:41 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rnj94-005tT8-G4 for pgsql-sql@lists.postgresql.org; Fri, 22 Mar 2024 17:57:40 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 42MHvX4s986897; Fri, 22 Mar 2024 13:57:33 -0400 From: Tom Lane To: Bindra Bambharoliya cc: Erik Brandsberg , pgsql-sql@lists.postgresql.org Subject: Re: Cursor with hold for select takes too long In-reply-to: References: Comments: In-reply-to Bindra Bambharoliya message dated "Fri, 22 Mar 2024 23:17:11 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <986895.1711130253.1@sss.pgh.pa.us> Date: Fri, 22 Mar 2024 13:57:33 -0400 Message-ID: <986896.1711130253@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Bindra Bambharoliya writes: > Query is like > Select a.id, sum(b.amount), > Count(c.am_id) ... from fact.a join fact.b on a.id= b.id join > Fact.vw_c on a.ida=vw_c.ida group by a.id; Is the query plan the same for cursor execution as regular? Compare EXPLAIN SELECT ... versus EXPLAIN DECLARE x CURSOR FOR SELECT ... (I'm not sure that WITH HOLD would make a difference, so maybe compare with and without that, too.) regards, tom lane