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 1scnqe-00Aa9L-5O for pgsql-hackers@arkaria.postgresql.org; Sat, 10 Aug 2024 15:17:40 +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 1scnqc-009N4m-QK for pgsql-hackers@arkaria.postgresql.org; Sat, 10 Aug 2024 15:17:38 +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 1scnqc-009N4e-Fm for pgsql-hackers@lists.postgresql.org; Sat, 10 Aug 2024 15:17:38 +0000 Received: from mail-il1-x12d.google.com ([2607:f8b0:4864:20::12d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1scnqV-00494n-7H for pgsql-hackers@postgresql.org; Sat, 10 Aug 2024 15:17:36 +0000 Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-39aeccc6377so10917955ab.1 for ; Sat, 10 Aug 2024 08:17:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723303049; x=1723907849; darn=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=TKu0uapcCxKu5qWtK94sPlTNg0e5CnbWbs5oLOBsx5U=; b=DSRXtyrnA2uSFgxzmYpIqQT9LKUu/rysKvFWhqaDW1Q4TEuQDyModcdlLNkvAYrggQ ROo9ULfGttAfzgdh5DG8m/HLA2cXE8EygeDbD9v5X5jrbCEzT1z/zmjVQmldu/fTiyU/ FPioL7RyLOQ9GjraPNtAm1LjQQ6WwWkJEDGBy2YsWT0fJRds+VOpLnIYC8NRSc+tRV2+ 6IMzpnjvEZ+XOsKlg3wYJUrhffiiQDYVlGNdiOKDNRIB7edZEnsNPrAnHh3VTDakN4lf xTJYMp94K9K8TtEtNBqaWZQzpnfGPUAi18X7toH5Lvs0/mpiGNsD+2jvZlIyu+qCb7HN bi8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723303049; x=1723907849; 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=TKu0uapcCxKu5qWtK94sPlTNg0e5CnbWbs5oLOBsx5U=; b=lF5dPfYyQW+2Orih4OeEO5z4OYiDFoabmUCPnFiq7V4+mUq/A+OBYRd9Q/nvRC6hav P7tu+UeNeWph1qT1yOHxtWm0ZbHXUItxvfKV7d1/Xih0GFV8HxaLPErNH/uPITfFl7w8 RDjOdPtBRz2WjH6n2CF9FBONvtbwyeaKwRhyjKB3NO16nS0nszXAnOZ3GqqDh4QuNnsr D3Gby7cDt1+aIhS4f9bymTO9vPGs1Q70LbqK3hAVtmPfLs4D75FjGp5aQS2fwMY4tdV1 rBw/wbxXs2v69KQESWmFjXuCJmCuzFbquRi5bstZh9/kdFcmuON7qA9aefildjn70anN dC0g== X-Forwarded-Encrypted: i=1; AJvYcCVZ9QmCPeQV8MwRL91i0uUbBgYlDIim2W3GAURJUvYS/4+8zmA53cet5Eh5jV/4KrGtXCmsSkvwQDbOr+/ZYbh3QC90hqEmz0plbSx/ X-Gm-Message-State: AOJu0YwcEKQIMvw+7GJtGSBPXn3HjIetapppWMytjHcSsce4KDLGprpE zRxdTwkdczGCCD3L8b1OCC9hbeq9u2DtBf9Z6p3xRTd+sAjyVNBn X-Google-Smtp-Source: AGHT+IFh9xUr+hvK4siZ/RxuJXto0ZQsQE2EmT7UqwBuOoM1QFe+I//OpWruEKxVx69K+wU+HnmVCw== X-Received: by 2002:a05:6e02:1c2f:b0:39b:2669:4e44 with SMTP id e9e14a558f8ab-39b7495d909mr67631735ab.8.1723303049097; Sat, 10 Aug 2024 08:17:29 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-39c30ad7de5sm5878995ab.64.2024.08.10.08.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Aug 2024 08:17:28 -0700 (PDT) Date: Sat, 10 Aug 2024 10:17:27 -0500 From: Nathan Bossart To: Corey Huinker Cc: Ilya Gladyshev , Daniel Gustafsson , Robert Haas , Jeff Davis , PostgreSQL Hackers Subject: Re: optimizing pg_upgrade's once-in-each-database steps Message-ID: References: <10c1c8dd-4685-46d4-80be-56bdfca8659a@gmail.com> <60cbc507-4c36-4037-9af7-028b1c8455b5@gmail.com> 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 Fri, Aug 09, 2024 at 04:06:16PM -0400, Corey Huinker wrote: >> I'll admit I hadn't really considered pipelining, but I'm tempted to say >> that it's probably not worth the complexity. Not only do most of the tasks >> have only one step, but even tasks like the data types check are unlikely >> to require more than a few queries for upgrades from supported versions. > > Can you point me to a complex multi-step task that you think wouldn't work > for pipelining? My skimming of the other patches all seemed to be one query > with one result set to be processed by one callback. I think it would work fine. I'm just not sure it's worth it, especially for tasks that run one exactly one query in each connection. >> Furthermore, most of the callbacks should do almost nothing for a given >> upgrade, and since pg_upgrade runs on the server, client/server round-trip >> time should be pretty low. > > To my mind, that makes pipelining make more sense, you throw out N queries, > most of which are trivial, and by the time you cycle back around and start > digesting result sets via callbacks, more of the queries have finished > because they were waiting on the query ahead of them in the pipeline, not > waiting on a callback to finish consuming its assigned result set and then > launching the next task query. My assumption is that the "waiting for a callback before launching the next query" time will typically be pretty short in practice. I could try measuring it... >> Perhaps pipelining would make more sense if we consolidated the tasks a bit >> better, but when I last looked into that, I didn't see a ton of great >> opportunities that would help anything except for upgrades from really old >> versions. Even then, I'm not sure if pipelining is worth it. > > I think you'd want to do the opposite of consolidating the tasks. If > anything, you'd want to break them down in known single-query operations, > and if the callback function for one of them happens to queue up a > subsequent query (with subsequent callback) then so be it. By "consolidating," I mean combining tasks into fewer tasks with additional steps. This would allow us to reuse connections instead of creating N connections for every single query. If we used a task per query, I'd expect pipelining to provide zero benefit. -- nathan