From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: Can I get the number of results plus the results with a single query?
Date: Wed, 17 Aug 2022 11:26:34 +0200
Message-ID: <20220817092634.kp7atpc3zoqaovri@hjp.at> (raw)
In-Reply-To: <9BD56F4C-6781-427E-9E0A-BD7F2BD1CF89@yugabyte.com>
References: <75BBE3C5-D495-47B8-A81C-6359391E3B99@easesoftware.com>
<20220815181618.bkpg7jwf546qlvlb@hjp.at>
<C6C274DF-62A3-4E54-AC83-F0FB3D7017EC@yugabyte.com>
<20220816204238.sfrtsl73z4yoc2d2@hjp.at>
<9BD56F4C-6781-427E-9E0A-BD7F2BD1CF89@yugabyte.com>
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
[...]
>
>
> I see, Peter. You’d read the OP’s mind.
Not much mind-reading involved, I hope. The first sentence in the
message was:
| I like to have what I call “baby sitting” messages such as “Completed 15 out of 1023”.
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’d failed to. I saw the subject, you I assumed that the OP wanted
> the entire result set together with the count of the results. (After
> all, there’s no inflexions of “page” in the OP’s 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’t 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
«select count(*) ,,,» is indeed much faster than «select * ...» 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
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
Attachments:
signature.asc (application/pgp-signature, 832B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: hjp-pgsql@hjp.at
Subject: Re: Can I get the number of results plus the results with a single query?
In-Reply-To: <20220817092634.kp7atpc3zoqaovri@hjp.at>
References: <75BBE3C5-D495-47B8-A81C-6359391E3B99@easesoftware.com> <20220815181618.bkpg7jwf546qlvlb@hjp.at> <C6C274DF-62A3-4E54-AC83-F0FB3D7017EC@yugabyte.com> <20220816204238.sfrtsl73z4yoc2d2@hjp.at> <9BD56F4C-6781-427E-9E0A-BD7F2BD1CF89@yugabyte.com> <20220817092634.kp7atpc3zoqaovri@hjp.at>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox