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 1hxfp2-0007gK-Tg for pgsql-general@arkaria.postgresql.org; Tue, 13 Aug 2019 23:03:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hxfp1-000085-HY for pgsql-general@arkaria.postgresql.org; Tue, 13 Aug 2019 23:03:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hxfp1-00006e-3s for pgsql-general@lists.postgresql.org; Tue, 13 Aug 2019 23:03:19 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1hxfoy-0001cA-Mq for pgsql-general@lists.postgresql.org; Tue, 13 Aug 2019 23:03:17 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 5D1F45F79F; Tue, 13 Aug 2019 19:03:16 -0400 (EDT) Date: Tue, 13 Aug 2019 19:03:16 -0400 From: Stephen Frost To: Derek Hans Cc: Tom Lane , pgsql-general@lists.postgresql.org Subject: Re: GIST/GIN index not used with Row Level Security Message-ID: <20190813230316.GQ16436@tamriel.snowman.net> References: <12552.1565723566@sss.pgh.pa.us> <14241.1565725716@sss.pgh.pa.us> <20190813213930.GO16436@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="7R/oUIX7ilUHG0fO" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --7R/oUIX7ilUHG0fO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Greetings, Please don't top-post on these lists. * Derek Hans (derek.hans@gmail.com) wrote: > Thanks for the detailed response, super helpful in understanding what's > happening, in particular understanding the risk of not marking functions as > leakproof. I'll take a look at the underlying code to understand what's > involved in getting a function to be leakproof. Great. > That said, it does seem like it should be possible and reasonable to > specify that a user should have access to the table stats so that the query > planner works as expected. Maybe it comes down to the fact that RLS is > still a work in progress, and I shouldn't be relying on it unless I'm > really certain it supports the functionality I need. PostgreSQL is still very much a work in progress. :) > I've updated word_similarity_op(text,text) to be leakproof, and > pg_proc agrees it is. I'm assuming word_similarity_op() is equivalent to > <%, though I haven't found explicit confirmation. However, using > word_similarity() instead of <% on a 100k row table, without any RLS > involved, doesn't make use of the index, while using <% does. Obviously, > adding the RLS doesn't make that any better. Any idea what might be the > cause? Just to be clear, you should be looking at pg_operator (oprcode) to determine the function that is under the operator that you wish to change to being leakproof. Note that the selectivity functions are associated with the operator, not the function itself. Thanks, Stephen --7R/oUIX7ilUHG0fO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJdU0G0AAoJEO1sijiDR2RVmxEP/1tlAnx1f7sjbYPYZ7t0X57q TYzrC2QLwUFEWJVQhHpIvB0YDL3QOM6v2ABZ5z3EOSS4aKDq7Qrm1K9OxqsNBoBB 4NZD5IMfqB3C2h2AcicCBeFlxnUcqJN+yUxf+Ncx2qWyK9ZeE8BXqPwA7/6T+fDp XdVhMioPCT+TBlLWDtIwZxBjp1tlVNj2/s/BM8vp5uzmeQSycmeFQYqlWRLDV6dh MSj7Cd/0luztGZanyTV2tDuCYojbd6Yz58YxBWc90ngSi3vtE9LYaPizBPZJat4d fxy7AAWHYOEAjyx+SfYp/yba959WKcG+KKnQHWVO2K5JAyu7+Ab6RO5bqFz77OfP DbAnyfuHm6kPVAmI+mjpDcIj/vPg8FrCNdd/fW77Xnrj+xj75j8eRQCFV9SxtWdq SzBNBiSLwuqSdWNZ/8ZqE7U/fX9x8WZq8sOHzApaUl9BBoJqO4aypuEPLxW03WsD nRUi5KE4iLyPoZjsM4gr/9ivV6SRZ9woj2ZDa3E//Xw407l5CghqLwFqSFwEon5W YcoerHdgy1iQz8k1IR3PNFP7Ji8F8lTiURJHSOKyrDLyfASzE+KWZXok53Kzbf+m 9p9itXTaJpHuPR38pKtiAtptTqzDfMP3Nl1PV0+GTNjQXImXDFzz4Z92gTkMJH7A zs1CE3ML0vVowB8YC/GY =ypFn -----END PGP SIGNATURE----- --7R/oUIX7ilUHG0fO--