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 1lLqax-0000FC-Vb for pgsql-general@arkaria.postgresql.org; Mon, 15 Mar 2021 17:01:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lLqaw-0007t0-TB for pgsql-general@arkaria.postgresql.org; Mon, 15 Mar 2021 17:01:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lLqaw-0007st-La for pgsql-general@lists.postgresql.org; Mon, 15 Mar 2021 17:01:30 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lLqau-0000ZJ-Dy for pgsql-general@lists.postgresql.org; Mon, 15 Mar 2021 17:01:29 +0000 Received: by mail-ej1-x62a.google.com with SMTP id ci14so67326724ejc.7 for ; Mon, 15 Mar 2021 10:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=UKuuomfmaENwYWlM5blJqX16750tqfgWj1DoxX5hbIc=; b=Dsr73xkETU7UjpoZWewNU7OGF4l4jOKzgAu6Qz495yhqmke6fsWfbJ5IqxoXIXyCMA ajg2QbX4JvVpGVuxDkkHMnn5wPr0vOL9Ab/LhL7QbhlHXe5asxCFKa3NBTZhkjELhwfF BRsX6MisfwhXbnxWcBURI78bGon3L36gBr/ANFz2EqAK41UXFWcYUi5JlX3ZdbxXJhAX YBFAa0ohZxRZhftue//xaT7r91EljM2F93TwzY8P0pUW5AGYO5I8jMQ71ISXgqM3pQx5 Mue9jjTJjxIF/wq5Uiv5UD6wMb7962tG7z1Tc2VJsbg1B+xJIieNbrNZx9psga/HL2zn Rnhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=UKuuomfmaENwYWlM5blJqX16750tqfgWj1DoxX5hbIc=; b=lYm0MdSFnSAbsjYLK0IQj8yw37WiKvzsLcDfDatsfEO7UDcZOoebUuH9TxcMhDPFhp h+bvrGXV+pnS4ZBABLy9b1ZjgsGq2E9FSg7z3PyAMbiGqg4drd2k4XE2t9/mdAXLCiHY Sejy5k9+mECPh+ULH9A9lA15EepSJl1OblENkCM+PNUIDJTPyjg6nf6nxaNJzOxg7KVV 0CcRYJ1br+5kVOMRRRR97FoGvWhuYv5DkPXsAua2TQ7r/ZkS8QwFlN7SW/aVkpijsezl SGImXfH0c32dlpQLb6/MVZCjVJRlS/6EOfv9BElln4+W/VjI6WkUBalYnOjovw3mzEV+ lhnA== X-Gm-Message-State: AOAM530Q7HLj2Vnul3kmSHytblwP5Zg3mbwvcLtEOpfABqk7lJ/EdOZF wXACG2wlkBmQ91DHb2bryhnswA== X-Google-Smtp-Source: ABdhPJxiWtzaCqMuPq0Uzqvx7wgsrV+/EjBiDD2wdU2uuFcSpIClslgmp4d2STF7dHCxCI2TLCi9BQ== X-Received: by 2002:a17:906:719b:: with SMTP id h27mr24380896ejk.123.1615827684771; Mon, 15 Mar 2021 10:01:24 -0700 (PDT) Received: from localhost.localdomain (217-149-171-45.nat.highway.telekom.at. [217.149.171.45]) by smtp.gmail.com with ESMTPSA id e18sm7634804eji.111.2021.03.15.10.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 10:01:24 -0700 (PDT) Message-ID: <667a19a588a9cf3a61d185e4cbe285df0a2f3cee.camel@cybertec.at> Subject: Re: Fwd: row level security (RLS) From: Laurenz Albe To: Rafal Pietrak , pgsql-general Date: Mon, 15 Mar 2021 18:01:23 +0100 In-Reply-To: References: <1bd6056c-10f9-5d63-a6ec-cbd10798acf9@ztk-rp.eu> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2021-03-15 at 16:28 +0100, Rafal Pietrak wrote: > 5. My experiments with RLS was like following: > - I've implemented a STABLE function, that returns INTEGER 1/0 > - I've linked that function as POLICY to my tables > - I've GRANTED PUBLIC access to those tables > ---> and all works as predicted.... only slow (10x slower!). > > [lots of questions about how to solve this is some other way] > > Those questions come from my bad experience with POLICY performance. You should figure out why RLS was so slow. The key to this is "EXPLAIN (ANALYZE, BUFFERS)" for the query - that will tell you what is slow and why, so that you can tackle the problem. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com