Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jJMPG-0000FF-8A for pgsql-general@arkaria.postgresql.org; Tue, 31 Mar 2020 19:18:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jJMPE-000746-9G for pgsql-general@arkaria.postgresql.org; Tue, 31 Mar 2020 19:18:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jJMPE-00073z-1B for pgsql-general@lists.postgresql.org; Tue, 31 Mar 2020 19:18:36 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jJMP7-0005kg-5v for pgsql-general@lists.postgresql.org; Tue, 31 Mar 2020 19:18:35 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 02VJIMGO023830; Tue, 31 Mar 2020 15:18:22 -0400 From: Tom Lane To: Alastair McKinley cc: "pgsql-general@lists.postgresql.org" Subject: Re: Index selection issues with RLS using expressions In-reply-to: References: Comments: In-reply-to Alastair McKinley message dated "Tue, 31 Mar 2020 18:53:24 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23828.1585682302.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 31 Mar 2020 15:18:22 -0400 Message-ID: <23829.1585682302@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alastair McKinley writes: > I am running in to an issue with RLS and index selection in my queries. = I created a toy example to try to illustrate the issue below. Postgres v= ersion is PostgreSQL 12.2 (Debian 12.2-2.pgdg100+1) on x86_64-pc-linux-gnu= , compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit. > Is there some subtle reason as to why the role "new_user" cannot seem to= generate a query plan that uses the gin index? The && operator is not marked leakproof, so it can't be applied till after the RLS filter, making an indexscan with it impossible when RLS is active. Perhaps arrayoverlap() itself could be proven leakproof, but the underlying type-specific equality operator might or might not be. We don't have enough infrastructure to handle indirect leakproofness requirements like that, so you lose :-( regards, tom lane