Re: getting count for a specific querry - Mailing list pgsql-sql

From Rod Taylor
Subject Re: getting count for a specific querry
Date
Msg-id 1112979092.92363.250.camel@home
Whole thread Raw
In response to Re: getting count for a specific querry  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
> > 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.
-- 



pgsql-sql by date:

Previous
From: Stef
Date:
Subject: Numeric and CSV under 8.0.1 ?
Next
From: Ragnar Hafstað
Date:
Subject: Re: getting count for a specific querry