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 1rpBqX-005WTe-Sq for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 18:48:30 +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 1rpBqW-003Hq6-Is for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 18:48:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rpBqW-003Hor-5H for pgsql-hackers@lists.postgresql.org; Tue, 26 Mar 2024 18:48:28 +0000 Received: from mail-il1-x12c.google.com ([2607:f8b0:4864:20::12c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rpBqR-006d4B-Dh for pgsql-hackers@lists.postgresql.org; Tue, 26 Mar 2024 18:48:27 +0000 Received: by mail-il1-x12c.google.com with SMTP id e9e14a558f8ab-3689a0abfd2so7046015ab.2 for ; Tue, 26 Mar 2024 11:48:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711478901; x=1712083701; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=82KRXOITdZA3be3E3x78JAXBTJ9mUobtcQzxjKgW6VY=; b=BymQGmH2MCOj/KPyaeUEB2mU2FVHM5zEccc5pWnKHA8q1FfsVynlAdnmvwVNiHZrca UchBqTZnTytBRDF/mcvbYv0iqfaxmIu4FBnk/b+27Ly6BPJmbodq5cOFPX3reTkRVH5T Yy0wdYv+6Zq9ekqJbcXCFxoOQ40dFznWzZymnKJsur/36I71Nz6OMIHIjUQIYU5GP6yj usK/lySiFxQ5lPq7nTCUPp/kLm70XnnzwL3a5HGm7UuBQbGSROoUH6yAKnTsiAX/tqo/ CB/Gc5eycZcMHnnzmQ2aRYWSqAY5dKjtLRUzKtMp1sNI7lXdSJK6QrlfGb39P9+nUo1+ PvNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711478901; x=1712083701; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=82KRXOITdZA3be3E3x78JAXBTJ9mUobtcQzxjKgW6VY=; b=UG5UtDedqWzvluA/mSr8/TZeRuDKs0xKb3+HKms4Dov4CQ97B+K9MuPxmkrqdranCD o7ChpnkHhB4VsNK4eecYjMZvQuG/g2rBLOC8ExhgivWEH8fVPt2szCYA2KbSkJgewwV6 IQKqDb6zFIFSp0ttGoifCJSa3HV+SwMEGYbP5KqRBEru/cigcig73k/oo9DJPW9UAuV9 X+qV8lg7l0Ec7WAjC4OuPLjcsC/u7GvlW/IGmayJGOv2bGEEHvkwJrHYvVlRm8TP0mo2 MfxJpphxe1hALc6oggRSCTrfwRFZOMTLBa0oQDAlxen8sJkjVfJ2bJBy0qjFz7tW5LD0 WX6g== X-Gm-Message-State: AOJu0Yw/ST1LmLnXUWwRKG57l7hnOA2IkWDOjEBvIiB4Q8J9mltckqWd 8BtyU2VL9KyQ/plhexQjGClO8BRkwV6UxCddLRbfZOuOEXOkzv+c9y4poxEW X-Google-Smtp-Source: AGHT+IH4T7SZ6dbVqLxZHUn7jnrdpK7Y8n0j7C5nG4t9mRQs//2vFrCPTkw1gRS9X23GEMtQv0eG9w== X-Received: by 2002:a92:db46:0:b0:368:7e1e:7e00 with SMTP id w6-20020a92db46000000b003687e1e7e00mr3760885ilq.7.1711478901642; Tue, 26 Mar 2024 11:48:21 -0700 (PDT) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id c4-20020a056e020cc400b00364228350d4sm489894ilj.84.2024.03.26.11.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 11:48:20 -0700 (PDT) Date: Tue, 26 Mar 2024 13:48:19 -0500 From: Nathan Bossart To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org, alex work , Robert Haas Subject: Re: Slow GRANT ROLE on PostgreSQL 16 with thousands of ROLEs Message-ID: <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> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3V7upXqbjpZ4EhLz" Content-Disposition: inline In-Reply-To: <2999167.1711476963@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Mar 26, 2024 at 02:16:03PM -0400, Tom Lane wrote: > I did a little experimentation using the attached quick-hack C > function, and came to the conclusion that setting up the bloom filter > costs more or less as much as inserting 1000 or so OIDs the dumb way. > So we definitely want a threshold that's not much less than that. Thanks for doing this. > So I'm now content with choosing a threshold of 1000 or 1024 or so. Cool. > As for the bloom filter size, I see that bloom_create does > > bitset_bytes = Min(bloom_work_mem * UINT64CONST(1024), total_elems * 2); > bitset_bytes = Max(1024 * 1024, bitset_bytes); > > which means that any total_elems input less than 512K is disregarded > altogether. So 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. > I do not like, even a little bit, your use of a static variable to > hold the bloom filter pointer. That code will misbehave horribly > if we throw an error partway through the role-accumulation loop; > the next call will try to carry on using the old filter, which would > be wrong even if it still existed which it likely won't. It's not > that much worse notationally to keep it as a local variable, as I > did in the attached. Ah, yes, that's no good. I fixed this in the new version. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --3V7upXqbjpZ4EhLz Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v4-0001-Optimize-roles_is_member_of-with-a-Bloom-filter.patch"