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

Re: SQL_CALC_FOUND_ROWS equivalent in PostgreSQL

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
Cc: "Matt Arnilo S(dot) Baluyos (Mailing Lists)" <matt(dot)baluyos(dot)lists(at)gmail(dot)com>, pgsql-novice(at)postgresql(dot)org
Subject: Re: SQL_CALC_FOUND_ROWS equivalent in PostgreSQL
Date: 2007-07-31 14:32:16
Message-ID: 20070731143216.GA28226@winnie.fuhr.org (view raw or flat)
Thread:
Lists: 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

In response to

pgsql-novice by date

Next:From: Paul MalherbeDate: 2007-08-01 12:33:56
Subject: Querying multiple tables
Previous:From: Oliver ElphickDate: 2007-07-31 10:20:31
Subject: Re: tsearch2.sql and different versions of PostgreSQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group