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 1rpAA2-005Ng3-UF for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 17:00:31 +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 1rpA92-001Fci-Hz for pgsql-hackers@arkaria.postgresql.org; Tue, 26 Mar 2024 16:59:28 +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 1rpA92-001FaZ-3m for pgsql-hackers@lists.postgresql.org; Tue, 26 Mar 2024 16:59:28 +0000 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rpA8t-006YtH-V7 for pgsql-hackers@lists.postgresql.org; Tue, 26 Mar 2024 16:59:26 +0000 Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-7c89cd8df36so122624739f.1 for ; Tue, 26 Mar 2024 09:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711472360; x=1712077160; 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=YU76pRJm5H2ayKixiRgGYYpXugXD2Mniawnjh73u+xs=; b=EX96Z6AoGYMBU5ysUfRtzWtPTRGyhmphnokW1ELd8t0ceubIOuIyCkfnWMkNdA19vW 2IZWr0+Xj9/ez+E8dSmsHGoRqHp6KxeG5442TPr2Zc9Tj4QRRcX2Rlk2IjqCxF5UZHIl QfEjk4JweBqpk5L7GDLuX07Y5SG4uCc3zoUOoijusd/VD3Zsdbv8kflvN5xZR/WZz4cr SKt28syvIwrxMox71eIE0ZTSBSpm6egjpHE0EiadUVO/TNGHoEcR0IS326IMYRa8ozCd xX8hBrmai1jBN+6H9lMUCp6heWovfCu3rARw0amlM03v6MgLMhcTLSSipo6n4pOx/2Rh Jv0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711472360; x=1712077160; 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=YU76pRJm5H2ayKixiRgGYYpXugXD2Mniawnjh73u+xs=; b=dKehrYXJ9Qpo3bWiz4QvxmKIeJMTIla0yHTWRfxjkbeS6RaAUSoIPODJ8H1pWAnpdb 9P6gf19FTKiN46MvHNxmE+oJl0nDCsK/2oct6AKIcDR64NY2aHbUvXxGevqdY67q2dO0 7Fsmp7RQbyogBiXBjTJcA/2nJWvZpkkov4R32o3TPzUIC4kD/NMyE0Vu8YerlGdy9ZUb uub9T2q8jIGayEKs+bU9cAhThRh4g731vH11h98tsb9aePCACeWkQQxsEk8MEmt/Nm55 B2go7JNR+yycHRrmWKojrvW8NgDrql9BhdR3vm74FiVRmyVfOPDFveFKnzYOFWx0LmvG 9Hwg== X-Gm-Message-State: AOJu0YzYLgQMMD9936D9zevjJSdaD2/agRQcKlDLj9IumGH8mOLified zSd42RWW6l2bG6fcBY4K3sZRdpamgLQCc++o95vLVsIINkINdmq5 X-Google-Smtp-Source: AGHT+IHiNBbgUFT+pbQrtLvJ40NjYY5SK9x/bOo8FKBOqMr8YzAHKnn8RE9jxukz53U5VarM8hRT0Q== X-Received: by 2002:a6b:e507:0:b0:7d0:76ba:e430 with SMTP id y7-20020a6be507000000b007d076bae430mr106009ioc.20.1711472360098; Tue, 26 Mar 2024 09:59:20 -0700 (PDT) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id p20-20020a0566380e9400b0047be708f348sm2885757jas.18.2024.03.26.09.59.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 09:59:19 -0700 (PDT) Date: Tue, 26 Mar 2024 11:59:18 -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: <20240326165918.GA3350222@nathanxps13> References: <20240322145532.GA2346110@nathanxps13> <907785.1711121266@sss.pgh.pa.us> <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> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="HlL+5n6rz5pIUxbD" Content-Disposition: inline In-Reply-To: <20240325151647.GA2662364@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --HlL+5n6rz5pIUxbD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Here is a new version of the patch that I feel is in decent shape. On Mon, Mar 25, 2024 at 10:16:47AM -0500, Nathan Bossart wrote: > On Mon, Mar 25, 2024 at 11:08:39AM -0400, Tom Lane wrote: >> * The magic constants (crossover list length and bloom filter size) >> need some testing to see if there are better values. They should >> probably be made into named #defines, too. I suspect, with little >> proof, that the bloom filter size isn't particularly critical --- but >> I know we pulled the crossover of 1000 out of thin air, and I have >> no certainty that it's even within an order of magnitude of being a >> good choice. > > I'll try to construct a couple of tests to see if we can determine a proper > order of magnitude. I spent some time trying to get some ballpark figures but have thus far been unsuccessful. Even if I was able to get good numbers, I'm not sure how much they'd help us, as we'll still need to decide how much overhead we are willing to take in comparison to the linear search. I don't think ~1000 is an unreasonable starting point, as it seems generally more likely that you will have many more roles to process at that point than if the threshold was, say, 100. And if the threshold is too high (e.g., 10,000), this optimization will only kick in for the most extreme cases, so we'd likely be leaving a lot on the table. But, I will be the first to admit that my reasoning here is pretty unscientific, and I'm open to suggestions for how to make it less so. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --HlL+5n6rz5pIUxbD Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0001-Optimize-roles_is_member_of-with-a-Bloom-filter.patch"