Is it possible to get the number of items as well as the list of items without re-executing the query?

10 views
Skip to first unread message

Perry Smith

unread,
Aug 12, 2022, 4:39:24 PM8/12/22
to ruby-pg
I have a non-Rails, Ruby project using “pg” and Postgres 14.

I like what I call “baby sitting messages” which are print statements that say “22% complete”.  To do that I need the number of elements that a result returns as well as the elements themselves.  Is there a way to do this, assuming the results are too big to just cache up locally in the client, without executing the query twice?  I’ve considered trying a weird join but that is going to get really messy.  I thought perhaps the number of elements a query produces is already buried somewhere in what Postgres returns to the client and so I thought I would ask.
Reply all
Reply to author
Forward
0 new messages