Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxcmp-0000hh-Hu for pgsql-general@arkaria.postgresql.org; Tue, 13 Aug 2019 19:48:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hxcmk-0000lL-CZ for pgsql-general@arkaria.postgresql.org; Tue, 13 Aug 2019 19:48:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxcmk-0000lD-30 for pgsql-general@lists.postgresql.org; Tue, 13 Aug 2019 19:48:46 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxcmd-0002e7-CY for pgsql-general@lists.postgresql.org; Tue, 13 Aug 2019 19:48:45 +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 x7DJmaEU014242; Tue, 13 Aug 2019 15:48:36 -0400 From: Tom Lane To: Derek Hans cc: pgsql-general@lists.postgresql.org Subject: Re: GIST/GIN index not used with Row Level Security In-reply-to: References: <12552.1565723566@sss.pgh.pa.us> Comments: In-reply-to Derek Hans message dated "Tue, 13 Aug 2019 15:31:25 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14240.1565725716.1@sss.pgh.pa.us> Date: Tue, 13 Aug 2019 15:48:36 -0400 Message-ID: <14241.1565725716@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Derek Hans writes: >> However, wild-guess time: it might be that without access to the >> table statistics, the "search like '%yo'" condition is estimated >> to be too unselective to make an indexscan profitable. And putting >> RLS in the way would disable that access if the ~~ operator is not >> marked leakproof, which it isn't. > I didn't realize you could set access to table statistics. How do I enable > this access for this user? You don't --- there's a hard-wired restriction against applying leaky operators to the table statistics, because they might leak values that the current user isn't supposed to be able to see. Overriding that would pretty much destroy the value of RLS. It's possible you could get away with marking ~~ (textlike) as leakproof. The default marking is based on the assumption that textlike might throw errors based on its RHS input not being a valid pattern ... but I think the only such error is "LIKE pattern must not end with escape character", and maybe that's not a big enough leak to concern you. > If that's not possible, it sounds like it > effectively blocks the use of GIN/GIST indexes when RLS is in use. There's a whole lot of daylight between "it doesn't pick an indexscan in this one example" and "it effectively blocks the use of GIN/GIST". regards, tom lane