From: Rod Taylor <pg@rbt.ca>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org, Joel Fradkin <jfradkin@wazagua.com>
Cc: Ragnar Hafstaư <gnari@simnet.is>
Subject: Re: getting count for a specific querry
Date: Fri, 08 Apr 2005 12:51:32 -0400
Message-ID: <1112979092.92363.250.camel@home> (raw)
In-Reply-To: <15084.1112977923@sss.pgh.pa.us>
References: <000001c53c3e$f4f5b730$797ba8c0@jfradkin>
<1112977546.7447.39.camel@localhost.localdomain>
<15084.1112977923@sss.pgh.pa.us>
> > 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.
--
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: pg@rbt.ca, tgl@sss.pgh.pa.us, jfradkin@wazagua.com, gnari@simnet.is
Subject: Re: getting count for a specific querry
In-Reply-To: <1112979092.92363.250.camel@home>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox