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 1qWOj8-0037nM-KM for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Aug 2023 22:10:54 +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 1qWOi7-00A7SD-Eq for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Aug 2023 22:09: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 1qWOi6-00A7S4-VM for pgsql-hackers@lists.postgresql.org; Wed, 16 Aug 2023 22:09:51 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qWOi2-000Vyr-70 for pgsql-hackers@postgresql.org; Wed, 16 Aug 2023 22:09:48 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bf092a16c9so3810265ad.0 for ; Wed, 16 Aug 2023 15:09:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20221208.gappssmtp.com; s=20221208; t=1692223785; x=1692828585; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=4Td2yjr8mhdAjOqYB67Dhh/EEE9IYHdJ1okOYrObdEQ=; b=VrUUU539Sbf6PRRCJl/SgUocDCmrQRCamJpivfNjU88CIPGi87PSp4qzuhdh77oStY gk4ecHN7BnBqZyIUpxIvn+q5Wn6JUe2K9oaDn6BkV5g9Q28jjp6avqWxF7dc1WzyjKSJ gtp/xbTvPSaXhTjGPTWO39F6SOIZ5t+/gzNBY4qqsHX/vw0F3EFTLZ/kv/1bDfHnVshh ncWdu7YQEt4RZEIbbhRDbGaQVmeZAvWQd9SpnDamEtL1CCUNFJzXzHXRVHeQgrCBVZeT dEXcblmgiU7xNLgfBRL7M8IwNov2WF+tdmRg4Q9Lhx1VXshg3AOMQxH1KmVE/Nwt4+bl gBwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692223785; x=1692828585; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=4Td2yjr8mhdAjOqYB67Dhh/EEE9IYHdJ1okOYrObdEQ=; b=cNPrs27CG00WbnyyGUxm/5Ba4ykyENd+o5hOnjfr2hhxhbL+yb1jPL+Teau5PSgBRf 3g8PG8fu3NwnUXdAmzfi2ZnR79zK5ULxAVjUOIg4R9dpwIJkrbuJm21EEfebv8S6MLuq AIq5c2XjGEpj2Gj5FJ5TT6DoyFbU9n8d7yZuClnt7blf6xQ75xIxEsUMQMPVmW6S00PE xiKoMja3RFWWqmQpHybK0ldp5Kdn4k2zT9P/H19vwiTcU6F+tvayvBqOPUm/kEr2u3hS P0OK2yhinTOpsFcyOWjLrQhNw6Zfw19AABq9dZBofTcZbYLRmwEhaubeyNKk/xZCA24X +hMg== X-Gm-Message-State: AOJu0Yz+GhOmQdMkQKNlCVIrhAzhFWG75zMNa+TKuWAzUMwhh+MfbtDa UP+gryxYCr7mzukEfgGm1BbTVg== X-Google-Smtp-Source: AGHT+IHMzNxhMlRuGFGf0LvfGjXPZ2fZDo9uwGFyxcQkcnjtEDFGzmlnfm9znKYMQTlN9WHsruuyvw== X-Received: by 2002:a17:902:e742:b0:1ac:5717:fd5 with SMTP id p2-20020a170902e74200b001ac57170fd5mr3783203plf.60.1692223785236; Wed, 16 Aug 2023 15:09:45 -0700 (PDT) Received: from [172.24.1.43] ([12.126.244.130]) by smtp.gmail.com with ESMTPSA id i16-20020a17090332d000b001bde65894c8sm6209057plr.268.2023.08.16.15.09.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 15:09:44 -0700 (PDT) Message-ID: <262cdb8a87c5e1fdb59ef2559c2a4a6006410dff.camel@j-davis.com> Subject: Re: Faster "SET search_path" From: Jeff Davis To: Robert Haas Cc: Nathan Bossart , Isaac Morland , pgsql-hackers@postgresql.org Date: Wed, 16 Aug 2023 15:09:43 -0700 In-Reply-To: References: <04c8592dbd694e4114a3ed87139a7a04e4363030.camel@j-davis.com> <20230802050720.GB866741@nathanxps13> <20230807223908.GB1284531@nathanxps13> <1c422b8a7f893550144a7aa4f4989ba1209ccba4.camel@j-davis.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2023-08-15 at 13:04 -0400, Robert Haas wrote: > I suspect that dodging the GUC stack machinery is not a very good > idea. The timing of when TRY/CATCH blocks are called is different > from > when subtransactions are aborted, and that distinction has messed me > up more than once when trying to code various things. ... > I can't say there isn't a way to make something like what you're > talking about here work, but I bet it will be difficult to get all of > the corner cases right, and I suspect that trying to speed up the > existing mechanism is a better plan than trying to go around it. The SearchPathCache that I implemented (0003) is an example of speeding up the existing mechnism that and already offers a huge speedup. I'll focus on getting that in first. That patch has had some review and I'm tempted to commit it soon, but Nathan has requested another set of eyes on it. To bring the overhead closer to zero we need to somehow avoid repeating so much work in guc.c, though. If we don't go around it, another approach would be to separate GUC setting into two phases: one that does the checks, and one that performs the final change. All the real work (hash lookup, guc_strdup, and check_search_path) is done in the "check" phase. It's a bit painful to reorganize the code in guc.c, though, so that might need to happen in a few parts and will depend on how great the demand is. Regards, Jeff Davis