Double query (limit and offset)
От | Michael Landin Hostbaek |
---|---|
Тема | Double query (limit and offset) |
Дата | |
Msg-id | 20051011151105.GA29943@mich2.itxmarket.com обсуждение исходный текст |
Ответы |
Re: Double query (limit and offset)
Re: Double query (limit and offset) |
Список | pgsql-sql |
List, I'm using the OFFSET / LIMIT combo in order to split up my query, so it only parses 20 rows at a time (for my php-scripted webpage). I'm using two queries; the first basically doing a select count(*) from [bla bla]; the second grabbing the actual data while setting LIMIT and OFFSET. In addition, I'm using the first query plus some calculations to parse total hits to the query, and number of pages etc etc. Now, my problem is this, the first query is simply counting all rows from the main table, whereas the second query has plenty of JOINS, and a GROUB BY statement - it's a fairly heavy query. The total (reported by the first query), it not at all the same as the amount of rows returned by the second query. I'd like to avoid having to run the "heavy" query twice, just in order to get the number of rows. Is there a smarter way of doing it ? Thanks, /mich
В списке pgsql-sql по дате отправления: