Re: Slow GRANT ROLE on PostgreSQL 16 with thousands of ROLEs - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: Slow GRANT ROLE on PostgreSQL 16 with thousands of ROLEs
Date
Msg-id 20240322015251.GA2193900@nathanxps13
Whole thread Raw
In response to Re: Slow GRANT ROLE on PostgreSQL 16 with thousands of ROLEs  (Nathan Bossart <nathandbossart@gmail.com>)
Responses Re: Slow GRANT ROLE on PostgreSQL 16 with thousands of ROLEs
List pgsql-hackers
On Thu, Mar 21, 2024 at 08:03:32PM -0500, Nathan Bossart wrote:
> On Thu, Mar 21, 2024 at 08:59:54PM -0400, Tom Lane wrote:
>> However ... I just remembered that we have a Bloom filter implementation
>> in core now (src/backend/lib/bloomfilter.c).  How about using that
>> to quickly reject (hopefully) most role OIDs, and only do the
>> list_member_oid check if the filter passes?
> 
> Seems worth a try.  I've been looking for an excuse to use that...

The Bloom filter appears to help a bit, although it regresses the
create-roles.sql portion of the test.  I'm assuming that's thanks to all
the extra pallocs and pfrees, which are probably avoidable if we store the
filter in a long-lived context and just clear it at the beginning of each
call to roles_is_member_of().

        HEAD  hash  hash+bloom
create  2.02  2.06  2.92
grant   4.63  0.27  0.08

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com

Attachment

pgsql-hackers by date:

Previous
From: Vik Fearing
Date:
Subject: Re: Catalog domain not-null constraints
Next
From: alex work
Date:
Subject: Re: Slow GRANT ROLE on PostgreSQL 16 with thousands of ROLEs