Paginating data, has to be a better way

Posted by John Tyler on Stack Overflow See other posts from Stack Overflow or by John Tyler
Published on 2010-06-17T16:14:33Z Indexed on 2010/06/17 16:23 UTC
Read the original article Hit count: 240

Filed under:
|
|

I've read like 10 or so "tutorials", and they all involve the same thing:

  • Pull a count of the data set
  • Pull the relevant data set (LIMIT, OFFSET)

IE:

SELECT COUNT(*) 
  FROM table 
 WHERE something = ?

SELECT * 
  FROM table 
 WHERE something =? 
 LIMIT ? offset ?`

Two very similar queries, no? There has to be a better way to do this, my dataset is 600,000+ rows and already sluggish (results are determined by over 30 where clauses, and vary from user to user, but are properly indexed of course).

© Stack Overflow or respective owner

Related posts about php

Related posts about postgresql