Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oOFK1-0007Ja-7F for pgsql-general@arkaria.postgresql.org; Wed, 17 Aug 2022 09:26:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oOFK0-0004a2-1p for pgsql-general@arkaria.postgresql.org; Wed, 17 Aug 2022 09:26:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oOFJz-0004Zc-NO for pgsql-general@lists.postgresql.org; Wed, 17 Aug 2022 09:26:43 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oOFJt-0002Xy-6o for pgsql-general@lists.postgresql.org; Wed, 17 Aug 2022 09:26:41 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 558E47853; Wed, 17 Aug 2022 11:26:34 +0200 (CEST) Date: Wed, 17 Aug 2022 11:26:34 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: Can I get the number of results plus the results with a single query? Message-ID: <20220817092634.kp7atpc3zoqaovri@hjp.at> Mail-Followup-To: pgsql-general@lists.postgresql.org References: <75BBE3C5-D495-47B8-A81C-6359391E3B99@easesoftware.com> <20220815181618.bkpg7jwf546qlvlb@hjp.at> <20220816204238.sfrtsl73z4yoc2d2@hjp.at> <9BD56F4C-6781-427E-9E0A-BD7F2BD1CF89@yugabyte.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="b6xdn7jzeilarbhh" Content-Disposition: inline In-Reply-To: <9BD56F4C-6781-427E-9E0A-BD7F2BD1CF89@yugabyte.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --b6xdn7jzeilarbhh Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2022-08-16 14:42:48 -0700, Bryn Llewellyn wrote: > hjp-pgsql@hjp.at wrote: > The OP wants some kind of progress indicator. To be useful, such > an indicator should be approximately linear in time. I.e. if your [...] >=20 >=20 > I see, Peter. You=E2=80=99d read the OP=E2=80=99s mind. Not much mind-reading involved, I hope. The first sentence in the message was: | I like to have what I call =E2=80=9Cbaby sitting=E2=80=9D messages such a= s =E2=80=9CCompleted 15 out of 1023=E2=80=9D. That's what I would call a "progress indicator". Such things were already common when I first got involved with computers almost 40 years ago, so there isn't much to guess or to invent. > But I=E2=80=99d failed to. I saw the subject, you I assumed that the OP w= anted > the entire result set together with the count of the results. (After > all, there=E2=80=99s no inflexions of =E2=80=9Cpage=E2=80=9D in the OP=E2= =80=99s question.) I don't think his question was about paging. That's a different although related topic. > It sounds like the OP wants a fast approximate count for a query whose > restriction isn=E2=80=99t known until runtime. Maybe an approximate count would be enough, but he didn't say so. (He did later clarify that he's fetching a lot of data for each row, so =C2=ABselect count(*) ,,,=C2=BB is indeed much faster than =C2=ABselect * .= =2E.=C2=BB due to the sheer amount of data to be transferred. That wasn't obvious from his first message, but I hedged against the possibility in my answer.) hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --b6xdn7jzeilarbhh Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmL8tEMACgkQ8g5IURL+ KF3O9A//Xf1wPd8HZ1Ylu3kLvl8W4hqVZNiy9E8OkC2R38ZPcfnZ9d739q6ZNEWR 6X671ePf9qpkYcE19POsoH4MgDF44YxUQY440ob1Tt+fZzVlgO4QVwOfe0NKyXOx aEW2Q2KVkl5+HF2rVIF0HjDYw2/WWbnIYcISnaHmukYRoQzUYghXxSE28y6vGflj mp3PTg2TCllZPhjylC42IJQb+Q4WjvFQyto3Z2yR4zxaPODg0FMMiZE+Zkio7WEP 3N/IIJXkbzI060iAtztxCDiJ2lhk72lAKE49yaB04y/JFn6r4xe/EA2Uwhi0Ktg4 bsvrxG5MJ9aajZivQKpVmXJeZKTCMX1dJNfZ/ZnTrZxgEqNQ8ognmpmf3jijiVwm wbXNqUhdpRtZBtE/1c+muGLbcF4uUYgYgWghOJG1KB7/lSUGijaZpDp732J+oWNr iwn5bWq64GV+Mt7xGZX3G2O+0O2jeAYpT9RkVDsBQNl1s0EeFVsupFegZfSf6Zq2 734Fb8Je2LAH78fRu/ABoi4T9gHvdbvxoqOI/s33kzkJ3Hp6zzm+4JvK+uQaMLd/ RSGxNdO0seLD34EucpNecSbPQEYWLMa+CglYk8tIjfiO350n/5qTNm6HZ9ngNGhy Nmx72zZHUJOavANqvLd5RJIr6QIVuFhdrlpJ7V8zk2HOMg1UClY= =mczA -----END PGP SIGNATURE----- --b6xdn7jzeilarbhh--