pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ragnar Hafstaư <gnari@simnet.is>
Cc: Joel Fradkin <jfradkin@wazagua.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: getting count for a specific querry
Date: Fri, 08 Apr 2005 12:32:03 -0400
Message-ID: <15084.1112977923@sss.pgh.pa.us> (raw)
In-Reply-To: <1112977546.7447.39.camel@localhost.localdomain>
References: <000001c53c3e$f4f5b730$797ba8c0@jfradkin>
	<1112977546.7447.39.camel@localhost.localdomain>

Ragnar =?ISO-8859-1?Q?Hafsta=F0?= <gnari@simnet.is> writes:
> you might reduce the performance loss if your dataset is ordered by
> a UNIQUE index.

> select * from mytable where somecondition 
>                       ORDER by uniquecol limit 50;

> and next:

> 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 ...

			regards, tom lane



view thread (38+ messages)  latest in thread

Message-ID: <15084.1112977923@sss.pgh.pa.us>
Permalink:  ../15084.1112977923@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/15084.1112977923@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, gnari@simnet.is, jfradkin@wazagua.com
  Subject: Re: getting count for a specific querry
  In-Reply-To: <15084.1112977923@sss.pgh.pa.us>

* 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