Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qJ00K-0002US-S7 for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Jul 2023 23:09:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qJ00J-0008Ec-G7 for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Jul 2023 23:09:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qJ00J-0008ES-5j for pgsql-hackers@lists.postgresql.org; Mon, 10 Jul 2023 23:09:15 +0000 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qJ00G-0039Y9-7Y for pgsql-hackers@lists.postgresql.org; Mon, 10 Jul 2023 23:09:13 +0000 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6682909acadso2684382b3a.3 for ; Mon, 10 Jul 2023 16:09:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689030550; x=1691622550; 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=G1Q3vA9Z4d07fEFv3UghjwKw1FUuRuVWwNvCwpTrcF0=; b=caEbTJfZkWTGCrRyJlWQ9DOOlOGFXd3d4pMF+dRMq0tI009hgAApClKMiUlrfQFKlL WYe5fLWbuUuq8OKK52CsF2Y/i7do3Qq1/yYdwjf36TQgqBMTbrxYdrDrXfkePYzOoWpr gwBX8tmM1HxUjjx7Y3upE0+GjY3wZEfgktAQcsgwsa4NHB7XNovXbqsW/snHgfgfk93Z FTPtTlKY0iqEkqKd6QiDYFgZLAAh4k/qIGp12xpv7TDRFgeRzM4aXPsr8tDUnsLhd3+D hKyKIf5meYqG5X/htspZKb/lNhYXkWOsiRnCX8SSMaGe8wol7ps3DjXBuHncIthvHX2I HBdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030550; x=1691622550; 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=G1Q3vA9Z4d07fEFv3UghjwKw1FUuRuVWwNvCwpTrcF0=; b=hNaQLwHhrwZ+wznPPtOV3z4TgaZFX6nwPSpLu4s4znU6L7vToRGNQBSIl8R9ttwbDT Z+RVvK/HsgZQdz51zJI+EdpgKBoWj1j33w1XYB98Udwx563V24lgpk2fr3e6/geM3dLW +7uFSucPmK6E/SSWq516gWdb7HXintFDO8t6qmt7CcQJtpoJDYcRNgZF+7/0jj7v3M6a d8Q1MKbtPfLPhj/2fMDpEVgPGwH8NurEiSiCX0wkvkPxvJ1G9d4Z726m9kggTLdNpQiQ 0zE4+X7ECt5tQ5gFIPwhpWCfZePgvAOha+e+lBgRohErryCKRxUHbQzFmZHdUT8um8BO Rm+Q== X-Gm-Message-State: ABy/qLY3ThXANgNSm+j9iXYqHaaw7ucItltlYMZ5UGWpc8vk/7b0koz6 14GBOz9mSOL2c1f4MneagWhOQmmU3eI= X-Google-Smtp-Source: APBJJlE6S7xpfVKhNO4d5jubrZDD8JUSrj6jtq110XupkrvHaynPgg3VLjG6s53UgWwdfaoyAHbuJA== X-Received: by 2002:a05:6a20:938f:b0:12e:caac:f252 with SMTP id x15-20020a056a20938f00b0012ecaacf252mr14580384pzh.1.1689030549954; Mon, 10 Jul 2023 16:09:09 -0700 (PDT) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id n2-20020a62e502000000b00682936d04ccsm286411pff.180.2023.07.10.16.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:09:09 -0700 (PDT) Date: Mon, 10 Jul 2023 16:09:07 -0700 From: Nathan Bossart To: Daniel Gustafsson Cc: PostgreSQL Hackers Subject: Re: Reducing connection overhead in pg_upgrade compat check phase Message-ID: <20230710230907.GA481155@nathanxps13> References: <20230218054613.GA3360104@nathanxps13> <542946CF-0D77-446E-9FA6-028982175320@yesql.se> <20230222192006.GA79448@nathanxps13> <235E7E38-6DCA-4E5F-812C-7F3033FC800A@yesql.se> <89A64E5D-D3DC-4806-B038-CD493F5F5510@yesql.se> <20230313182147.GA294021@nathanxps13> <20230704190839.GA3468243@nathanxps13> <9C9D8A09-9794-46DD-8074-8961924B99F1@yesql.se> <20230708214354.GA4044380@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jul 10, 2023 at 04:43:23PM +0200, Daniel Gustafsson wrote: >> On 8 Jul 2023, at 23:43, Nathan Bossart wrote: >> Since "script" will be NULL and "db_used" will be false in the first >> iteration of the loop, couldn't we move this stuff to before the loop? > > We could. It's done this way to match how all the other checks are performing > the inner loop for consistency. I think being consistent is better than micro > optimizing in non-hot codepaths even though it adds some redundancy. > > [ ... ] > >> Won't "script" always be initialized here? If I'm following this code >> correctly, I think everything except the fclose() can be removed. > > You are right that this check is superfluous. This is again an artifact of > modelling the code around how the other checks work for consistency. At least > I think that's a good characteristic of the code. I can't say I agree with this, but I'm not going to hold up the patch over it. FWIW I was looking at this more from a code simplification/readability standpoint. >> +static int n_data_types_usage_checks = 7; >> >> Can we determine this programmatically so that folks don't need to remember >> to update it? > > Fair point, I've added a counter loop to the beginning of the check function to > calculate it. + /* Gather number of checks to perform */ + while (tmp->status != NULL) + n_data_types_usage_checks++; I think we need to tmp++ somewhere here. >> In fact, I wonder if we could just add the versions directly to >> data_types_usage_checks so that we don't need the separate hook functions. > > We could, but it would be sort of contrived I think since some check <= and > some == while some check the catversion as well (and new ones may have other > variants. I think this is the least paint-ourselves-in-a-corner version, if we > feel it's needlessly complicated and no other variants are added we can revisit > this. Makes sense. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com