X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CE371536DB for ; Fri, 8 Apr 2005 17:32:10 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 71342-06 for ; Fri, 8 Apr 2005 16:32:05 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id D291953671 for ; Fri, 8 Apr 2005 17:32:03 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j38GW3Hh015085; Fri, 8 Apr 2005 12:32:03 -0400 (EDT) To: Ragnar =?ISO-8859-1?Q?Hafsta=F0?= Cc: Joel Fradkin , pgsql-sql@postgresql.org Subject: Re: getting count for a specific querry In-reply-to: <1112977546.7447.39.camel@localhost.localdomain> References: <000001c53c3e$f4f5b730$797ba8c0@jfradkin> <1112977546.7447.39.camel@localhost.localdomain> Comments: In-reply-to Ragnar =?ISO-8859-1?Q?Hafsta=F0?= message dated "Fri, 08 Apr 2005 16:25:46 -0000" Date: Fri, 08 Apr 2005 12:32:03 -0400 Message-ID: <15084.1112977923@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/99 X-Sequence-Number: 20992 Ragnar =?ISO-8859-1?Q?Hafsta=F0?= 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