Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rpC9a-005Xrw-BM for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 19:08:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rpC9Y-003er4-NC for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 19:08:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rpC9Y-003eqw-DY for pgsql-hackers@lists.postgresql.org; Tue, 26 Mar 2024 19:08:08 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rpC9R-006Zro-7I for pgsql-hackers@lists.postgresql.org; Tue, 26 Mar 2024 19:08:07 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 42QJ800K3088177; Tue, 26 Mar 2024 15:08:00 -0400 From: Tom Lane To: Nathan Bossart cc: pgsql-hackers@lists.postgresql.org, alex work , Robert Haas Subject: Re: Slow GRANT ROLE on PostgreSQL 16 with thousands of ROLEs In-reply-to: <20240326184819.GA3559028@nathanxps13> References: <20240322163952.GA2347986@nathanxps13> <939945.1711126395@sss.pgh.pa.us> <20240322165448.GA2350322@nathanxps13> <20240322193506.GA2352051@nathanxps13> <1084642.1711140109@sss.pgh.pa.us> <20240325144743.GA2618709@nathanxps13> <2490242.1711379319@sss.pgh.pa.us> <20240325151647.GA2662364@nathanxps13> <20240326165918.GA3350222@nathanxps13> <2999167.1711476963@sss.pgh.pa.us> <20240326184819.GA3559028@nathanxps13> Comments: In-reply-to Nathan Bossart message dated "Tue, 26 Mar 2024 13:48:19 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3088175.1711480080.1@sss.pgh.pa.us> Date: Tue, 26 Mar 2024 15:08:00 -0400 Message-ID: <3088176.1711480080@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Nathan Bossart writes: > On Tue, Mar 26, 2024 at 02:16:03PM -0400, Tom Lane wrote: >> ... I'm not sold on your "ROLES_LIST_BLOOM_THRESHOLD * 10" >> value. Maybe it doesn't matter though. > Yeah, I wasn't sure how much to worry about this. I figured that we might > as well set it to a reasonable estimate based on the description of the > parameter. This description claims that the filter should work well if > this is off by a factor of 5 or more, and 50x the threshold sounded like it > ought to be good enough for anyone, so that's how I landed on 10x. But as > you point out, this value will be disregarded altogether, and it will > continue to be ignored unless the filter implementation changes, which > seems unlikely. If you have a different value in mind that you would > rather use, I'm fine with changing it. No, I have no better idea. As you say, we should try to provide some semi-reasonable number in case bloom_create ever starts paying attention, and this one seems fine. >> I do not like, even a little bit, your use of a static variable to >> hold the bloom filter pointer. > Ah, yes, that's no good. I fixed this in the new version. My one remaining suggestion is that this comment isn't very precise about what's happening: * If there is a previously-created Bloom filter, use it to determine * whether the role is missing from the list. Otherwise, do an ordinary * linear search through the existing role list. Maybe more like * If there is a previously-created Bloom filter, use it to try to * determine whether the role is missing from the list. If it * says yes, that's a hard fact and we can go ahead and add the * role. If it says no, that's only probabilistic and we'd better * search the list. Without a filter, we must always do an ordinary * linear search through the existing list. LGTM other than that nit. regards, tom lane