Re: READ UNCOMMITTED in postgres

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: READ UNCOMMITTED in postgres
Date: 2019-12-19 06:54:47
Message-ID: 7d37e627-9717-6acf-9ad5-f357d5d0f147@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Matthew Phillips schrieb am 19.12.2019 um 00:12:
> Hi, 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.

In my understanding READ UNCOMMITTED in other databases is typically used to avoid read-locks which Postgres doesn't have.
So I wonder what benefits READ UNCOMMITTED would have to begin with.

But, if you want to poll for new rows, then why don't you use a timestamp column?

select *
from the_table
where created_at >= <last check time>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Simon Riggs 2019-12-19 08:19:46 Re: READ UNCOMMITTED in postgres
Previous Message Tom Lane 2019-12-19 00:06:27 Re: AccessExclusiveLock with pg_locks.locktype of tuple