Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: SQL_CALC_FOUND_ROWS equivalent in PostgreSQL



On Tue, Jul 31, 2007 at 07:24:34AM +0100, Oliver Elphick wrote:
>    BEGIN;
>    SELECT * FROM mytable OFFSET X LIMIT Y;
>    SELECT COUNT(*) AS total FROM mytable;
>    END;
> 
> (To ensure consistent results, both queries should be done in a single
> transaction.)

To ensure consistent results the transaction should be SERIALIZABLE.
With the default of READ COMMITTED changes between the two selects
would be visible to the second select.

-- 
Michael Fuhr



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group