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 1rxTbS-0091ts-DF for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Apr 2024 15:23:10 +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 1rxTbQ-0067Y2-Ql for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Apr 2024 15:23:08 +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 1rxTbQ-0067Xt-HE for pgsql-hackers@lists.postgresql.org; Thu, 18 Apr 2024 15:23:08 +0000 Received: from mail-oa1-x2d.google.com ([2001:4860:4864:20::2d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rxTbM-003TKc-QM for pgsql-hackers@postgresql.org; Thu, 18 Apr 2024 15:23:07 +0000 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-233e41de0caso534060fac.0 for ; Thu, 18 Apr 2024 08:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713453784; x=1714058584; 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=QEA9ozyRqqBBvva82JY3XJ65+g0VdR2lOwxbnJS6mxY=; b=EGoc4+cwaBTAr4ajYpdvup2zRbr7OvJY6Or9h2KXY/dalBGY+B5Rb7XmhmuFEwBBAW pnevbU35T8AB3/CRG1Ez/culYwzRiPgRGyBs4gPqxmcPcO5R/0z/awp6KuoWIBJjhlq2 40a+xmRgvtdtbvLz4wYcTXMO3ceTymRj+qmP7Nof6COSx2aq4R8HbRMs0U0wjkBLDudt zurQZWr3DdmLXcF+PbiriNaSdiynUHuEMB6C36tXU00+yVz3R6H5X93JIo5PXaGQJ1mF A/RLLmnmfAJEQ4uE2NOWXXlVk86ogWZrQVwLwby5FD5MC48ZZIwA+DHIr0//u+C20qoI T9Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713453784; x=1714058584; 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=QEA9ozyRqqBBvva82JY3XJ65+g0VdR2lOwxbnJS6mxY=; b=KzM2+jTVZv4mLACuBzqZp0OsWKeycoaCurKgLGZCcwc26592rzyJGJNNAq48BZQf98 uAb9JCyqInMn5RUPtv3yoa7bg+UVN5s+elx1jWYYj0E+D6H0AlqJXtf3cjLPF9roE21d DVao5dzEbxwV++TZIgC9NZig7cc4iJUW1fDX45C9yjAIDz5SOYICsTuBtvwMxPZpvcW/ KwquJmJdvEfW7TDLvOpGvYJqo4Udt1KT7V0+G+fe9Vg8NZosQwrLGQ/VLzt6hOK9JO8I XO/+yKvDmSZXtWYDrzUDScf0eWEAw3go2nuG/9VHVio+UAd8riFykjPWjBcsXKrJqNOe NQqg== X-Gm-Message-State: AOJu0Yw3hG9gPj9+1JG38AMeq5hKmwWAIWMMVfgy99WxDbHI/v8XfiMx XSoPhG8Ed+gokCUT0ZR4i/Fo/y+V+UCgO3p9GI5StKiM9TqPnkHGrC4CEw== X-Google-Smtp-Source: AGHT+IG/RIISCo1mc/5ljZG9TBHmEcyAIaiDpdlyBaCDeJ5j21chuSQO2caqjIzW6WqppXUJD3QlvQ== X-Received: by 2002:a05:6870:d148:b0:22e:dfd0:9a4f with SMTP id f8-20020a056870d14800b0022edfd09a4fmr3976469oac.24.1713453784063; Thu, 18 Apr 2024 08:23:04 -0700 (PDT) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id eh19-20020a056638299300b004827739872bsm472949jab.82.2024.04.18.08.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 08:23:03 -0700 (PDT) Date: Thu, 18 Apr 2024 10:23:01 -0500 From: Nathan Bossart To: Daniel Gustafsson Cc: PostgreSQL Hackers Subject: Re: improve performance of pg_dump --binary-upgrade Message-ID: <20240418152301.GB3501884@nathanxps13> References: <20240418041712.GA3441570@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 Thu, Apr 18, 2024 at 09:24:53AM +0200, Daniel Gustafsson wrote: >> On 18 Apr 2024, at 06:17, Nathan Bossart wrote: > >> The attached work-in-progress patch speeds up 'pg_dump --binary-upgrade' >> for this case. Instead of executing the query in every call to the >> function, we can execute it once during the first call and store all the >> required information in a sorted array that we can bsearch() in future >> calls. > > That does indeed seem like a saner approach. Since we look up the relkind we > can also remove the is_index parameter to binary_upgrade_set_pg_class_oids > since we already know that without the caller telling us? Yeah. It looks like that's been possible since commit 9a974cb, so I can write a prerequisite patch for this. >> One downside of this approach is the memory usage. > > I'm not too worried about the worst-case performance of this. Cool. That seems to be the general sentiment. >> This was more-or-less >> the first approach that crossed my mind, so I wouldn't be surprised if >> there's a better way. I tried to keep the pg_dump output the same, but if >> that isn't important, maybe we could dump all the pg_class OIDs at once >> instead of calling binary_upgrade_set_pg_class_oids() for each one. > > Without changing the backend handling of the Oid's we can't really do that > AFAICT, the backend stores the Oid for the next call so it needs to be per > relation like now? Right, this would require additional changes. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com