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 1rnizM-00EjNk-Ry for pgsql-sql@arkaria.postgresql.org; Fri, 22 Mar 2024 17:47:33 +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 1rnizL-006E2x-Ch for pgsql-sql@arkaria.postgresql.org; Fri, 22 Mar 2024 17:47:31 +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 1rnizL-006E2o-39 for pgsql-sql@lists.postgresql.org; Fri, 22 Mar 2024 17:47:31 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rnizC-005tNU-IK for pgsql-sql@lists.postgresql.org; Fri, 22 Mar 2024 17:47:30 +0000 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-5d8ddbac4fbso1547673a12.0 for ; Fri, 22 Mar 2024 10:47:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711129643; x=1711734443; 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=R0wj/AFDbUCk4uOVQKgDKtIqTmaCmzgbCdZFSzXOy70=; b=UFvxTLNDkxCHLBhpFLvnpdhhZCaismzR6bG+l/otiXwWDqhRus9aDz7AimUemY1Tab NnRdPtXrsVvwgwaTSgRsxWARmyu+/p8CahE031YDTxcoWK14RZwcQeUilAVDD7mX3o86 KRat896et/F9kF/Qv5NajgiPN1+DXzFZhV3Pcfs01W3fDpTwq9uNUpPM7IfJnK/pppZc GpaUB6721Kq/g2YPathplZE6WJwq3j2OAee4UzSjAw9ABakFo3gdJ3KjXzOrCHht9Fly MvEwCKfG3cbYPMlhkhCdq78BI3qCiIjBHYNzrk0sWhrDKu83F7q34MTBpJcZ3762zOj2 3hjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711129643; x=1711734443; 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=R0wj/AFDbUCk4uOVQKgDKtIqTmaCmzgbCdZFSzXOy70=; b=pss8KI6Wvtc6gqAEWZ49CcFSj19ACZM54xt3xRgPNMGWQTDGGcc8M8sauKQ300dcMr 5UcAs/sv3bZxof6QpJk2UBqSYF3SpnqIMH/NfUoDt5/perzva65XknR8bRNvKL8TVXAl ggecexsQbL9PahtWyzaZ46kroYhM1JxCt+e4fp5BpBL0ji2j0vZa4LhbCxnH3DVvQX00 pUTQ7HPsGqRSwa13QN4ZpiLWFHOM5R3IvgopUgD46eoHHkwTwHVd5ZdCkI8tethUWkJ/ QfPklMOk+jX3toxe1iHk2CN9QOIYdSTZ5YHrS4Tqw6z/G28LwOO0jLeYOKsQ/zNrxPYK 7U8A== X-Gm-Message-State: AOJu0YykV3DPH0Vp4c4MBSvVUvOIjJrSA/UP7v3tlGGyQhgRRIDVY/9P JxEqoZnV9Xft/0JSOAECZKsJ6SapWwTactQRv/ObMqEFmjV1DAsCgtMMbGGgBibXWLK5JtGHUOT bEOXfakNyD+7KcFg+Dx2+6dDH8uc= X-Google-Smtp-Source: AGHT+IFbWmR/w2/b00eTHHb4DmMpit2scDMdp59zf1hn+N4nY585zkEmF7+UDWj6mtOBLTU7cd/7v3qBvDpLel+4qAM= X-Received: by 2002:a17:90a:4c83:b0:29f:af2f:3f85 with SMTP id k3-20020a17090a4c8300b0029faf2f3f85mr358968pjh.43.1711129642687; Fri, 22 Mar 2024 10:47:22 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bindra Bambharoliya Date: Fri, 22 Mar 2024 23:17:11 +0530 Message-ID: Subject: Re: Cursor with hold for select takes too long To: Erik Brandsberg Cc: pgsql-sql@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000008469830614436a94" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000008469830614436a94 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi team, There is no order by, query returns 5341 rows. Query is like Select a.id, sum(b.amount), Count(c.am_id) ... from fact.a join fact.b on a.id=3D b.id join Fact.vw_c on a.ida=3Dvw_c.ida group by a.id; On Fri, 22 Mar 2024, 23:09 Erik Brandsberg, wrote: > What is the actual query being done, and how many rows are being > returned? Depending on the query, it could change the execution path, so > this is critical to understand. If you are doing an order by on a large > result-set, it may be doing a huge amount of processing to get your first > 100 rows. > > On Fri, Mar 22, 2024 at 12:50=E2=80=AFPM Bindra Bambharoliya < > bindra.bambharoliya@gmail.com> wrote: > >> Hi team, >> I am facing issues with cursor with hold for select. >> >> If I execute select quaery without cursor it takes 13 seconds, >> If execute it like >> Begin; >> Cursor "sql1" with hold for select.... ;fetch 100 to "sql1" >> It takes more than 3 minutes. >> Even sometimes it takes more than 10 minutes. >> >> What could be the problem? >> Request to help on this ASAP. >> I am facing this issue on production. >> I checked locks etc. But nothing like that. >> >> >> Thanks & Regards >> Bindra >> > --0000000000008469830614436a94 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi team,
There is no order by= , query returns 5341 rows.
Query is like=C2=A0
=
Select a.id, sum(b.amount),
Count(c.am_id) ... from fact.a join fact.b on a.id=3D b.id join
Fact.vw_c on a.ida=3Dvw_c.ida group by a.id;
=C2=A0


<= div class=3D"gmail_quote" dir=3D"auto">
On Fri, 22 Mar 2024, 23:09 Erik Brandsberg, <erik@heimdalldata.com> wrote:
What is the actual query being done, and= how many rows are being returned?=C2=A0 Depending on the query, it could c= hange the execution path, so this is critical to understand.=C2=A0 If you a= re doing an order by on a large result-set, it may be doing a huge amount o= f processing to get your first 100 rows.

On Fri, Mar 22, 2024 at 12:50=E2=80= =AFPM Bindra Bambharoliya <bindra.bambharoliya@gmail.com&= gt; wrote:
Hi team,
I am facing issues with cursor with = hold for select.

If I ex= ecute select quaery without cursor it takes 13 seconds,
If execute it like=C2=A0
Begin;
Cursor "sql1" with hold for select.... ;fetch 100 to "= ;sql1"
It takes more than 3 minutes.
Even sometimes it takes more than 10 minutes.

What could be the problem?
Request to help on this ASAP.
I am facing = this issue on production.=C2=A0
I checked locks etc.= But nothing like that.

=
Thanks=C2=A0& Regards
Bindra
--0000000000008469830614436a94--