From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alastair McKinley <a.mckinley@analyticsengines.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Poor plan choice with partial unique indexes on jsonb column and simple RLS policy (with test script)
Date: Tue, 03 Mar 2020 23:22:39 -0500
Message-ID: <22263.1583295759@sss.pgh.pa.us> (raw)
In-Reply-To: <DB6PR0201MB23415D13CB0F5BDDEC8923FCE3E50@DB6PR0201MB2341.eurprd02.prod.outlook.com>
References: <DB6PR0201MB23413E06B56707DF28B8013DE3E40@DB6PR0201MB2341.eurprd02.prod.outlook.com>
<11492.1583280280@sss.pgh.pa.us>
<DB6PR0201MB23415D13CB0F5BDDEC8923FCE3E50@DB6PR0201MB2341.eurprd02.prod.outlook.com>
Alastair McKinley <a.mckinley@analyticsengines.com> writes:
> Thank you for having a look at this. In the interim I discovered that I could trigger the issue by creating a security barrier view, whereas a regular view worked fine, so I think that also points to your conclusion about leakyness?
> I attempted to workaround the issue with a leakproof function, so far with no success.
> ...
> Is this an approach that could fundamentally work?
Forcing the expression to be considered leakproof should work.
I'm not sure that your partial index is OK for the purpose of
collecting stats, though -- does it help if you make a non-partial
index on that function expression? Otherwise, it's possible that
I guessed wrong about which part of the WHERE clause is problematic.
You could try doing EXPLAINs with different portions of the WHERE
to see how the rowcount estimate changes.
BTW, just marking something "leakproof" when it isn't really so
is possibly a security problem. You should think twice about
what threat model you're hoping RLS will protect against.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, a.mckinley@analyticsengines.com
Subject: Re: Poor plan choice with partial unique indexes on jsonb column and simple RLS policy (with test script)
In-Reply-To: <22263.1583295759@sss.pgh.pa.us>
References: <DB6PR0201MB23413E06B56707DF28B8013DE3E40@DB6PR0201MB2341.eurprd02.prod.outlook.com> <11492.1583280280@sss.pgh.pa.us> <DB6PR0201MB23415D13CB0F5BDDEC8923FCE3E50@DB6PR0201MB2341.eurprd02.prod.outlook.com> <22263.1583295759@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox