From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, alex work <alexwork033(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com> |
Subject: | Re: Slow GRANT ROLE on PostgreSQL 16 with thousands of ROLEs |
Date: | 2024-03-21 20:40:12 |
Message-ID: | 20240321204012.GA1992418@nathanxps13 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
On Thu, Mar 21, 2024 at 04:31:45PM -0400, Tom Lane wrote:
> I wrote:
>> ... I still see the problematic GRANT taking ~250ms, compared
>> to 5ms in v15. roles_is_member_of is clearly on the hook for that.
>
> Ah: looks like that is mainly the fault of the list_append_unique_oid
> calls in roles_is_member_of. That's also an O(N^2) cost of course,
> though with a much smaller constant factor.
>
> I don't think we have any really cheap way to de-duplicate the role
> OIDs, especially seeing that it has to be done on-the-fly within the
> collection loop, and the order of roles_list is at least potentially
> interesting. Not sure how to make further progress without a lot of
> work.
Assuming these are larger lists, this might benefit from optimizations
involving SIMD intrinsics. I looked into that a while ago [0], but the
effort was abandoned because we didn't have any concrete use-cases at the
time. (I'm looking into some additional optimizations in a separate thread
[1] that would likely apply here, too.)
[0] https://postgr.es/m/20230308002502.GA3378449%40nathanxps13
[1] https://postgr.es/m/20240321183823.GA1800896%40nathanxps13
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Gustafsson | 2024-03-21 23:23:15 | Re: pg_dumpall with flag --no-role-passwords omits roles comments as well |
Previous Message | Tom Lane | 2024-03-21 20:31:45 | Re: Slow GRANT ROLE on PostgreSQL 16 with thousands of ROLEs |
From | Date | Subject | |
---|---|---|---|
Next Message | Wolfgang Walther | 2024-03-21 20:44:16 | Re: Building with meson on NixOS/nixpkgs |
Previous Message | Tom Lane | 2024-03-21 20:31:45 | Re: Slow GRANT ROLE on PostgreSQL 16 with thousands of ROLEs |