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 1rnirz-00EihY-Mg for pgsql-sql@arkaria.postgresql.org; Fri, 22 Mar 2024 17:39:56 +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 1rniry-006ACu-6U for pgsql-sql@arkaria.postgresql.org; Fri, 22 Mar 2024 17:39:54 +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 1rnirx-006ACm-RP for pgsql-sql@lists.postgresql.org; Fri, 22 Mar 2024 17:39:54 +0000 Received: from mail-ua1-x92d.google.com ([2607:f8b0:4864:20::92d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rniru-005tEd-Fi for pgsql-sql@lists.postgresql.org; Fri, 22 Mar 2024 17:39:52 +0000 Received: by mail-ua1-x92d.google.com with SMTP id a1e0cc1a2514c-7e0425e5aa8so1064307241.3 for ; Fri, 22 Mar 2024 10:39:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heimdalldata.com; s=google; t=1711129190; x=1711733990; 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=ZBug+1ferfWrW5xB0MkAvDcocUKRFmMp+zK+Yztz+b8=; b=fmfDYE9e6eqcdSNjNCjoKQJ+ehCw8Hf6OY+4rqzC0GviSaAka/URmbmb/aC6uZb8mw fsbHLAut4sQ21j46bwepEeVkj45IYGML7dGyXYC6H2I/ckBCD4MtCNR9p+whC7K+hC1R 825G2Hh4Dohcc6hymBCoiz2h9t2oTjq9GdrIw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711129190; x=1711733990; 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=ZBug+1ferfWrW5xB0MkAvDcocUKRFmMp+zK+Yztz+b8=; b=XwHFpPCGq3xaBwcKKnSQT1+sUVhe+g3rUY5N7SVJRDKWrWNjSTrrpKtDaTstWYhYWG EHZawQO5Lp0elipo5qjN28itNeE2nCJfUBK9jhhLAdotvkxSI3m65INhmkciOIgJfzIh MBtDEJXKBQu/BLzPD+ghRYd1faxLhZ+NqSahFkpbDRclU4S4kJ5APszTKQPG9kOVdrDq 4wCIgNumBRQ6CXv0IAx9fG1xxC63YE+0Q01iZiImNGs3pDQvok6KqKCpg/LTFaObRFDI g87smG4aFZCUBiuohGIcukQ28VetYdETHcUZrHr3BU0e6Kta3vJa/aMefauKRBCivanq E7oA== X-Gm-Message-State: AOJu0YyWeWuxIHFaVaM5AB8HgLAkjDly6t6DItZtFzoA4t+2Ws0qQizz yqYEcBQQCVfGzKnIk2ZFen3ln8cPsQmrKDpDzlqxrj39jE9rtWUnD2R75qdPOxNQeCEK30EtRKB SL+0C12Oi2HbDwRMwByTqeaePSgnvXyrCjQt/6w== X-Google-Smtp-Source: AGHT+IGmWh5/CVThEiJXtWEIrupcirbjvR/iKYIe0myCuF7VA0qsdiWqbFrx9SJxfgz+XlyGu2Yqp72XsZf+rIgQJM4= X-Received: by 2002:a67:f055:0:b0:474:c9d9:a76f with SMTP id q21-20020a67f055000000b00474c9d9a76fmr299794vsm.22.1711129190479; Fri, 22 Mar 2024 10:39:50 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Erik Brandsberg Date: Fri, 22 Mar 2024 13:39:39 -0400 Message-ID: Subject: Re: Cursor with hold for select takes too long To: Bindra Bambharoliya Cc: pgsql-sql@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000009054ab0614434f33" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000009054ab0614434f33 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 > --0000000000009054ab0614434f33 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
What is the actual query being done, and how many rows are= being returned?=C2=A0 Depending on the query, it could change the executio= n path, so this is critical to understand.=C2=A0 If you are doing an order = by on a large result-set, it may be doing a huge amount of processing to ge= t your first 100 rows.

On Fri, Mar 22, 2024 at 12:50=E2=80=AFPM Bindra Bambh= aroliya <bindra.bambhar= oliya@gmail.com> wrote:
Hi team,
I am facing issu= es with cursor with hold for select.

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

What could be the pr= oblem?
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
--0000000000009054ab0614434f33--