> > select * from mytable where somecondition AND uniquecol>? > > ORDER by uniquecol limit 50 OFFSET 50; > > > where the ? is placeholder for last value returned by last query. > > Uh, you don't want the OFFSET there do you? But otherwise, yeah, > this is a popular solution for paging through some rows. Doesn't really > help with the problem of counting the total dataset though ...
In the past I've done an EXPLAIN and parsed the plan to see what PostgreSQL estimated for the number of <somecondition>. If less than $threshhold, I would do a count(*). If more than $threshhold I would display to the user "approx N records". This seemed to be good enough for most cases. -- ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster