From: Adam B. <ad...@po...> - 2002-06-12 23:07:47
|
> > One other thing for the PostgreSQL experts (ehem): am I correct that > > there is no way of knowing how many rows a cursor contains? Is it really > > the easiest solution to first do a SELECT COUNT on the same query? > Looks like so, but in the end I was able to do without knowing the total > number of rows. I'm not an expert, but I think that even PostgreSQL itself doesn't know the number of rows before all of them are fetched. Look at files at src/backend/executor directory, especially execMain.c and execProcnode.c. The main fetching loop is in ExecutePlan() function, which fetches rows one by one till ExecProcNode() returns nothing. PostgreSQL portals simply don't execute more than it is necessary to get the needed number of rows, whatever is the source of the data (a table, a view or even a SRF -- a "set returning function"). Regards, -- Adam Buraczewski <ad...@po...> * Linux registered user #165585 GCS/TW d- s-:+>+:- a- C+++(++++) UL++++$ P++ L++++ E++ W+ N++ o? K? w-- O M- V- PS+ !PE Y PGP+ t+ 5 X+ R tv- b+ DI? D G++ e+++>++++ h r+>++ y? |