This is not very clear to me as when we use a cursor on a very large table does pg (server) scan all the records loads them in a temporary waiting space until the client starts consuming it ? or if PG holds/pauses physical scan of all records until client has asked for next rows?
If its the second one then, does it scan on the snapshot of the table at the time when cursor was created so CRUD operations don't interfere? (is it then safe to say that cursor can be used to paginate the results without the need for order by clause as its working on point in time snapshot of the table and nothing can change?)
Also what happens when group by clause is added to a cursor query i assume in such a case it will be forced to scan all records on the tables save them in temp and return from it in batches?
The question is for whats the right way to paginate and read huge data table.