Getting number of matched records from query

Поиск
Список
Период
Сортировка
От Michael Owens
Тема Getting number of matched records from query
Дата
Msg-id 200311012254.06132.mike@mikesclutter.com
обсуждение исходный текст
Ответы Re: Getting number of matched records from query
Список pgsql-hackers
I should perhaps dig a little more on this one, but per the C API docs I don't 
think what I am asking for is available. This somewhat relates to count().

Is there a reasonable way that information regarding the number of matched 
records could be passed back to the client --- even in the case of a LIMIT? 
PQntuples() only returns the number of tuples in the result set (restricted by 
the limit clause). Is there a way to get all matched records in the query 
(before they were limited)? Perhaps this number could be sent back through 
PQcmdTuples(), in which case this would be the meaning of its return value 
for the SELECT queries.

This is useful in a limit/offset situation such as a web based search where 
you want to divide the results up over several pages. In order to display any 
kind of navigation, you need to know the total number of records up front so 
you can display to the client the number of pages it would take to step 
through all of the results, N records at a time. 

If this were available, then it would obviate the need to count(*) the query 
before executing it, which could save quite a bit of time.

Isn't this information (the number of matched records) available to the 
backend --- even in the case of LIMIT? All matched records still have to be 
materialized right? Therefore the record count should be available and could 
therefore be available to the client. Is this correct? 

I would be willing to work on implementing this, but I would just like to know 
if this is even possible first.




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Mark Wong
Дата:
Сообщение: Re: OSDL DBT-2 w/ PostgreSQL 7.3.4 and 7.4beta5
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: Getting number of matched records from query