Search Postgresql Archives

Re: Can I get the number of results plus the results with a single query?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2022-08-16 14:42:48 -0700, Bryn Llewellyn wrote:
>     hjp-pgsql@xxxxxx 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@xxxxxx         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachment: signature.asc
Description: PGP signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux