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 1sZZr2-001wLV-IQ for pgsql-hackers@arkaria.postgresql.org; Thu, 01 Aug 2024 17:44:44 +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 1sZZr0-00CNry-5W for pgsql-hackers@arkaria.postgresql.org; Thu, 01 Aug 2024 17:44:42 +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 1sZZqz-00CNrq-Ry for pgsql-hackers@lists.postgresql.org; Thu, 01 Aug 2024 17:44:41 +0000 Received: from mail-il1-x132.google.com ([2607:f8b0:4864:20::132]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sZZqx-002dsM-KF for pgsql-hackers@postgresql.org; Thu, 01 Aug 2024 17:44:41 +0000 Received: by mail-il1-x132.google.com with SMTP id e9e14a558f8ab-397ba4f7387so39749155ab.0 for ; Thu, 01 Aug 2024 10:44:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722534278; x=1723139078; 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=kjmbqS71pdqmTh+X5KqovdTbT4zL4BgR17VoEJSdouY=; b=NQxSR+xmkXBezL88sU7Qc7RVpRPcfw7PdRYO7hoDady741BwOBV0K/aVrfCWcBfdVP bDtMqVh5NjPJGePHrRftHdP/5iysxhynirA/S+2+nMDNrxV+OKfknD6jcdGdJe5NGinC m4DshrAXXRL5VPbZJqAzegmn4O/SXoY053zjUOKV7PIGbBYM6penOk/EvZ7AHukAMBA3 iDZUFMvoYxf5QWGmIF9TUU4ROpy+z+DKCoL6vXWFP6/kdYzgn7PHbVkp8KxVOBaeQiKe nB1q88v3Dpt2fjro7JopCGwb4G2ZYZaJmgENvDFtNgXCgS4uI77Gcdi/tH7PhkHS88i5 wBtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722534278; x=1723139078; 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=kjmbqS71pdqmTh+X5KqovdTbT4zL4BgR17VoEJSdouY=; b=NAYFZWEBL4VEslUwkGYbj7P5yxo+9vR3WdsSmCrRnh9CdGLufE1rp6rnTLeRp5sWUI xv01N9uP4OcnzScSfC6YQPWSXH3n2BvVrwIlidh6exarRh/U+r26PKQ5mDKaXwuvzEcl 4O00o9T6FsEcnYAgM+1b2/4jf5OtTlytNM3kcNkQkWKTjCC5PtjwC+qXAEuDxQNmnhQs IhJfKOdQvrVaO6gTbh1pPAbkrjwdwtRQ+W89jN+FdY5/12XpchXilXye/83hBQj9joJ/ Y2pvSE3hT8jXdjFbt/f+nfby4yqTsMSCBnek8G2r4Jzzd6EccnCkQbsEz197XVIqwDf8 lReg== X-Forwarded-Encrypted: i=1; AJvYcCUVpjp6vi/ByZz2pN23fJWOKGAEJINLzxwhkDAYTpk7zZYlhqPMOqqrr6NqqjANRQXp6JLtKSKUYj1mlMGMwOitcA8vYtaLBeQOr4EI X-Gm-Message-State: AOJu0YwrEVPBME5bc44/EYK1MWIV6CSJmRTG1TJJOUqJoda72r7BKXa3 XesbUAamAf9l+CbLrs65JI8KAjC/zlK3+LOOzxnkUgeC3NA8sQecm/HmZA== X-Google-Smtp-Source: AGHT+IEgvn1uAV6NbfPrhsV3CS8Xo8pTShsCwMxC0VlOXc0qS/J+lTQTWznTGwxIdwz0ZnmrTShssg== X-Received: by 2002:a05:6e02:4c8:b0:375:be9e:34da with SMTP id e9e14a558f8ab-39b1fb512c9mr11417525ab.2.1722534277623; Thu, 01 Aug 2024 10:44:37 -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-39b20af1688sm626405ab.73.2024.08.01.10.44.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 10:44:37 -0700 (PDT) Date: Thu, 1 Aug 2024 12:44:35 -0500 From: Nathan Bossart To: Ilya Gladyshev Cc: Daniel Gustafsson , Robert Haas , Jeff Davis , PostgreSQL Hackers Subject: Re: optimizing pg_upgrade's once-in-each-database steps Message-ID: References: <26742670-9539-4F30-B6FA-9C1DB743BC23@yesql.se> <4493D323-9726-48F7-A702-E71FB991F76B@yesql.se> <10c1c8dd-4685-46d4-80be-56bdfca8659a@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <10c1c8dd-4685-46d4-80be-56bdfca8659a@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jul 31, 2024 at 10:55:33PM +0100, Ilya Gladyshev wrote: > I like your idea of parallelizing these checks with async libpq API, thanks > for working on it. The patch doesn't apply cleanly on master anymore, but > I've rebased locally and taken it for a quick spin with a pg16 instance of > 1000 empty databases. Didn't see any regressions with -j 1, there's some > speedup with -j 8 (33 sec vs 8 sec for these checks). Thanks for taking a look. I'm hoping to do a round of polishing before posting a rebased patch set soon. > One thing that I noticed that could be improved is we could start a new > connection right away after having run all query callbacks for the current > connection in process_slot, instead of just returning and establishing the > new connection only on the next iteration of the loop in async_task_run > after potentially sleeping on select. Yeah, we could just recursively call process_slot() right after freeing the slot. That'd at least allow us to avoid the spinning behavior as we run out of databases to process, if nothing else. > +1 to Jeff's suggestion that perhaps we could reuse connections, but perhaps > that's a separate story. When I skimmed through the various tasks, I didn't see a ton of opportunities for further consolidation, or at least opportunities that would help for upgrades from supported versions. The data type checks are already consolidated, for example. -- nathan