public inbox for [email protected]
help / color / mirror / Atom feedFrom: PG Doc comments form <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Important topic is missed: comparing composite types
Date: Thu, 18 Sep 2025 02:26:00 +0000
Message-ID: <[email protected]> (raw)
The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/17/rowtypes.html
Description:
I am working with composites and found that they are a bit slower in compare
if I use separate columns.
It would be nice if article will contain description of the best approach
how to do comparison with composite types.
Here below is just overview of the problem.
CREATE TYPE tenant_ctx AS (
org_id int,
unit_id int,
user_id int
);
Eg.
(org_id, unit_id, user_id) = ( SELECT * FROM rls_guard_table_comp() ) # this
returns tenant_ctx
"(ouu) = (SEL * FROM fn()) <-- T Co; --> cs-ouu";
DO
Time: 475,272 ms
elapsed_ms
------------
475.061
(1 row)
Time: 0,044 ms
branch = ( select Co from rls_guard_table_comp() Co ) # branch is
tenant_ctx;
"Co = (SEL Co FROM fn() Co) <-- T Co; --> cs-ouu";
DO
Time: 1033,373 ms (00:01,033)
elapsed_ms
------------
1033.205
(1 row)
Time: 0,114 ms
((branch).org_id, (branch).unit_id, (branch).user_id) = ( SELECT org_id,
unit_id, user_id FROM rls_guard_table() )
"(Co.ouu) = (SEL ouu FROM fn()) <-- T ouu; --> cs-ouu";
DO
Time: 824,334 ms
elapsed_ms
------------
824.137
(1 row)
reply
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Important topic is missed: comparing composite types
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox