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 1rngoC-00EYOV-U9 for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Mar 2024 15:27:53 +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 1rngoA-004bVq-TX for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Mar 2024 15:27:51 +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 1rngoA-004bVi-KJ for pgsql-hackers@lists.postgresql.org; Fri, 22 Mar 2024 15:27:51 +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 1rngo7-005sAI-EN for pgsql-hackers@lists.postgresql.org; Fri, 22 Mar 2024 15:27:49 +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 42MFRknl907786; Fri, 22 Mar 2024 11:27:46 -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: <20240322145532.GA2346110@nathanxps13> References: <341186.1711037256@sss.pgh.pa.us> <619340.1711050134@sss.pgh.pa.us> <642442.1711053105@sss.pgh.pa.us> <20240321204012.GA1992418@nathanxps13> <20240322005139.GA2060816@nathanxps13> <806361.1711069194@sss.pgh.pa.us> <20240322144739.GA2321246@nathanxps13> <20240322145532.GA2346110@nathanxps13> Comments: In-reply-to Nathan Bossart message dated "Fri, 22 Mar 2024 09:55:32 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <907784.1711121266.1@sss.pgh.pa.us> Date: Fri, 22 Mar 2024 11:27:46 -0400 Message-ID: <907785.1711121266@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Nathan Bossart writes: > On Fri, Mar 22, 2024 at 09:47:39AM -0500, Nathan Bossart wrote: >> hash hash+simd hash+simd+bloom >> create 1.27 1.27 1.28 >> grant 0.18 0.11 0.03 > For just hash+bloom, I'm seeing 1.29 and 0.04. Yeah, that's about what I'd expect: hash+bloom ought to remove most (not quite all) of the opportunity for simd to shine, because the bloom filter should eliminate most of the list_member_oid calls. Possibly we could fix that small regression in the create phase with more careful tuning of the magic constants in the bloom logic? Although I'd kind of expect that the create step doesn't ever invoke the bloom filter, else it would have been showing a performance problem before; so this might not be a good test case for helping us tune those. I think remaining questions are: * Is there any case where the new hash catcache logic could lose measurably? I kind of doubt it, because we were already computing the hash value for list searches; so basically the only overhead is one more palloc per cache during the first list search. (If you accumulate enough lists to cause a rehash, you're almost surely well into winning territory.) * Same question for the bloom logic, but here I think it's mostly a matter of tuning those constants. * Do we want to risk back-patching any of this, to fix the performance regression in v16? I think that the OP's situation is a pretty narrow one, but maybe he's not the only person who managed to dodge roles_is_member_of's performance issues in most other cases. regards, tom lane