Re: RLS creates inaccurate limit and offset results

Christophe Pettus <xof@thebuild.com>

From: Christophe Pettus <xof@thebuild.com>
To: mike@mikebrancato.com
Cc: pgsql-bugs@lists.postgresql.org
Date: 2025-11-12T18:20:07Z
Lists: pgsql-bugs

> On Nov 11, 2025, at 14:46, mike@mikebrancato.com wrote:
> If I understand the documentation (https://www.postgresql.org/docs/current/queries-limit.html), inconsistent results for different LIMIT / OFFSET values is only a known issue when selecting different subsets of data.

The documentation could perhaps be better worded, but PostgreSQL makes no guarantee of the order of a result set in absence of an ORDER BY clause over that particular result set.  Since the ordering can't be guaranteed, which particular subset you get from LIMIT and OFFSET is not guaranteed either.

Again, this has nothing to do with RLS in particular.  The more complex the query and the more steps a result set has to go through from disk ordering to result set ordering, the more likely it is to see inconsistent results, but it's never guaranteed in any case.