I am curious to know if there is a command to obtain the number of records (tuples) in a cursor such as a count(*)? I have an app. using the libpq API that allows the user to search a database and then stores those results in a cursor... in turn, the app. allows the user to scroll through the resutls n at a time. However, I also want to display the total number of records returned from the search. It seems highly innefficient to do a SELECT count(*) and then standard SELECT of the same query... After declaring a cursor and passing resutls into it... is there a command, temporary table, or session in memory that I can obtain a total count of records for that cursor? Regards, Michael
Michael Dunn <michael@2cactus.com> writes:
> is there a command, temporary table, or session in memory that I can
> obtain a total count of records for that cursor?
Not short of reading out the tuples ... in general there is no way to
predict the number of tuples that a query will return, except by
computing them.
regards, tom lane
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера