Re: READ UNCOMMITTED in postgres

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Matthew Phillips <mphillips34(at)gmail(dot)com>
Cc: Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: READ UNCOMMITTED in postgres
Date: 2019-12-19 08:19:46
Message-ID: CANP8+jJY+fBXFgKZbrwyEUJbSGuUTLMcSSv-9M1zrgU6LxqVFA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 18 Dec 2019 at 23:13, Matthew Phillips <mphillips34(at)gmail(dot)com>
wrote:

> With the current READ UNCOMMITTED discussion happening on pgsql-hackers
> [1], It did raise a question/use-case I recently encountered and could not
> find a satisfactory solution for. If someone is attempting to poll for new
> records on a high insert volume table that has a monotonically increasing
> id, what is the best way to do it? As is, with a nave implementation, rows
> are not guaranteed to appear in monotonic order; so if you were to keep a
> $MAX_ID, and SELECT WHERE p_id > $MAX_ID, you would hit gaps. Is there a
> clean way to do this? I've seen READ UNCOMMITTED used for this with DB2.
>

Not sure it helps much. The new records aren't truly there until commit.

Using max_id alone is not an effective technique. It's just an optimization.

Just be careful to not advance max_id too quickly, and remember which ones
you've already checked. Or wait for the next monontonic value each time,
accepting the lag.

--
Simon Riggs http://www.2ndQuadrant.com/
<http://www.2ndquadrant.com/>
PostgreSQL Solutions for the Enterprise

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message James Sewell 2019-12-19 09:33:43 Max locks
Previous Message Thomas Kellerer 2019-12-19 06:54:47 Re: READ UNCOMMITTED in postgres