Important topic is missed: comparing composite types - Mailing list pgsql-docs

From PG Doc comments form
Subject Important topic is missed: comparing composite types
Date
Msg-id 175816236005.860.4057702842618093971@wrigleys.postgresql.org
Whole thread Raw
List pgsql-docs
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)

pgsql-docs by date:

Previous
From: Eugen Konkov
Date:
Subject: Re: The document contains false statements
Next
From: jian he
Date:
Subject: Re: CREATE TABLE LIKE(INCLUDING COMMENTS) description ignored STATISTICS