Re: Pagination - 1 or 2 queries? - Mailing list pgsql-general

From Bruce Momjian
Subject Re: Pagination - 1 or 2 queries?
Date
Msg-id 200309052103.h85L35Z18434@candle.pha.pa.us
Whole thread Raw
In response to Pagination - 1 or 2 queries?  (CSN <cool_screen_name90001@yahoo.com>)
List pgsql-general
CSN wrote:
>
> Behind the scenes, is there much performance
> difference between:
>
> SELECT *
> FROM table_with_millions_of_rows
> ORDER BY col1;
>
> and:
>
> SELECT *
> FROM table_with_millions_of_rows
> ORDER BY col1
> LIMIT 100
> OFFSET 100000;

Yes, the optimizer knows it doesn't have to execute the entire query, so
the later can be faster, but that doesn't return the COUNT(*), as
requested.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-general by date:

Previous
From: Adam Kavan
Date:
Subject: Re: Panic Index!!!!
Next
From: CSN
Date:
Subject: Re: Pagination - 1 or 2 queries?