From: Orion <o2@trustcommerce.com>
To: pgsql-sql@postgresql.org
Subject: count(*) and limit
Date: Thu, 11 Oct 2001 13:31:59 -0700
Message-ID: <9q4vc1$2nej$1@news.tht.net> (raw)
I have a interface where users are paging through results of a query. In
order to do so I need to
select count(*) from data where stuff;
To find out how many pages of data there are ( needed for the navigation
bar)
and then I need to
select * from data where stuff limit X offset y;
Now, postgres has to get the whole result before running the limit.
Is there some trick to get how many rows there would be without the limit
so I dont need to run the extra count(*) query? It seems like a waste.
Orion
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: o2@trustcommerce.com
Subject: Re: count(*) and limit
In-Reply-To: <9q4vc1$2nej$1@news.tht.net>
* 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