Re: SQL_CALC_FOUND_ROWS equivalent in PostgreSQL - Mailing list pgsql-novice

From Michael Fuhr
Subject Re: SQL_CALC_FOUND_ROWS equivalent in PostgreSQL
Date
Msg-id 20070731143216.GA28226@winnie.fuhr.org
Whole thread Raw
In response to Re: SQL_CALC_FOUND_ROWS equivalent in PostgreSQL  (Oliver Elphick <olly@lfix.co.uk>)
List pgsql-novice
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

pgsql-novice by date:

Previous
From: Oliver Elphick
Date:
Subject: Re: tsearch2.sql and different versions of PostgreSQL
Next
From: Paul Malherbe
Date:
Subject: Querying multiple tables