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 1tftlL-0061VE-DS for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Feb 2025 04:45:16 +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 1tftlJ-004IoI-Hl for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Feb 2025 04:45:13 +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 1tftlJ-004IoA-2j for pgsql-hackers@lists.postgresql.org; Thu, 06 Feb 2025 04:45:13 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tftlG-003Sj3-1i for pgsql-hackers@lists.postgresql.org; Thu, 06 Feb 2025 04:45:12 +0000 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2ef72924e53so858766a91.3 for ; Wed, 05 Feb 2025 20:45:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1738817109; x=1739421909; darn=lists.postgresql.org; 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=85W+eiWp050kCaqCpgpaZE+sN0AN+rsYUTn6BVUJvKQ=; b=PqAK67AUHuvlmSv6KKXNNV+VR42HblfPe8MAe7ftwlxIgdyYhmdEgcUJd20/ot98VG 5r78nvQuCeuCPGXxYcgdYywP7bLlM5s/avNtXfbLuVN41v29w4oU8ynapUkZPK2oWm1k 9mXPUe3nKb7ADfTdJO/RZHxdIZszWbvjp+Gm2K1DfUTxVg1KIMuGhhSCVQY5mvmwqNAz hdD0c3UUeXsuVN0cy7oHH00rThWZ8AtBwDBhohG7OKL2CDtzFs/emkjeNEV4VVDTHsKz a7+uvjYhw3tnbahCNO5zhjGvSTnaf0FxEh6bCzBPtgUmgB3RCqw59OovDXhBAmlisniU NzZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738817109; x=1739421909; 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=85W+eiWp050kCaqCpgpaZE+sN0AN+rsYUTn6BVUJvKQ=; b=q84a4T6agZsfYwyrpkCN0CaLnD79fgJjZOEZFtXCp+W8CyMzVuyBWLNgfjXQUv4r7l aCbtvhx9jJuOAZ78c2bB0oHnKKSzIRJg76PLnGRmY+bI2CDOdt+QousQLUeWl+rGthsE zQ9kkw2y96OgN4pqXJ6mW0fgTSKYZCvHNbzu3Csf42Hku8+vsnCMg7sEUpIxWaM1DWS2 RBzByDTJ1hBKrmPO/2jK1mcKJdGUSK9b6cXrZYwM8FrcV+XsLdcA0GyVLsDoNdvZvk/q yn8o8Gyw9tTU2bKLDnjH/Jk1pqqOPkSmky30a0Rz8Y9PPYEAhliotc8BM3PdzMB2HHEX h1fA== X-Forwarded-Encrypted: i=1; AJvYcCVFB6PwjgyDcpvvoVXtUN+N0TPfjCCXPkpFpLb9J7fEYt2mS2HovbAqAz4TdS8mv0PQdO2vHSz9NVElNDIL@lists.postgresql.org X-Gm-Message-State: AOJu0YxDtRokFpL6fXtlwN9NzqSNtxDNkhGGVazAVMiD0oGhKZeztn/f BlcpLT3XR6NWIoTyNSfDyKO/sOfK4hjmZn4newOvuix21Xh2sX4K+olq3W2BLQ== X-Gm-Gg: ASbGnctdrQYKaZwuBVElTs977kt4pTXAEkdaV5rmVn47EuatqPNrmP+drwmeUv/aL46 ph2TfrfLFS7+EiDEv+R9RM3pZaioe/B9umPLYDy5FuDnGOTmWpmozngbq17NcboIv8I9uNxl7vt Kk+2uz7hfuSOzMmv+9OjrvUYfodq0VMH1E0/iKZkSbDZkII1tABlZ1QkyQsQu5GYUc5KKmFLKog p0fPqASNru/+i+ehrRbWeDyaqZk2HsbQmY00q1oHIK+hwRvUxytdJxVyau7OaPuGSKnLH48kV7F zSj7i/OR9pQzdPPTjqM+a/+SitxLQZOtS99BpNRU6BtgsmM55UZhXnyrYg== X-Google-Smtp-Source: AGHT+IGaA/nBtVspBouwK5tBzp7chCo6WmzsqigCtikTcpFJXE2torA18CmUc3ts8ciuVXdko14aPw== X-Received: by 2002:a05:6a00:ac8:b0:728:e1e3:3d88 with SMTP id d2e1a72fcca58-730351257ccmr8720149b3a.7.1738817109369; Wed, 05 Feb 2025 20:45:09 -0800 (PST) Received: from jeff-laptop.lan (c-76-102-242-158.hsd1.ca.comcast.net. [76.102.242.158]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73048c1620asm333527b3a.136.2025.02.05.20.45.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Feb 2025 20:45:08 -0800 (PST) Message-ID: <0b4c098ae3968aa23d6accb691f47bdba143aedd.camel@j-davis.com> Subject: Re: Statistics Import and Export From: Jeff Davis To: Corey Huinker , jian he Cc: Nathan Bossart , Bruce Momjian , Matthias van de Meent , Tom Lane , Magnus Hagander , Stephen Frost , Ashutosh Bapat , Peter Smith , PostgreSQL Hackers , alvherre@alvh.no-ip.org, MichaelPaquier Date: Wed, 05 Feb 2025 20:45:06 -0800 In-Reply-To: References: <5d3a24216d15ce8a50d0fc085a13a410202014ca.camel@j-davis.com> <3bd40d2c686608196b8e04c2aaac9c57c447aae6.camel@j-davis.com> <39770e3aebfdf543fa2215fb300621a54b1b2634.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 Wed, 2025-02-05 at 23:01 -0500, Corey Huinker wrote: > And here's an update to the pg_dump code itself. This currently has > failing TAP tests for statistics in the custom and dir formats, but > is working otherwise. This thread got slightly mixed up, so I'm replying to the v45-0001 posted here, and also in response to Michael's and Corey's comments from: https://www.postgresql.org/message-id/Z5H0iRaJc1wnDVLE%40paquier.xyz On Thu, 2025-01-23 at 16:49 +0900, Michael Paquier wrote: > On Tue, Jan 21, 2025 at 10:21:51PM -0500, Corey Huinker wrote: > > After some research, I think that we should treat partitioned > > indexes like > > we were before, and just handle the existing special case for > > regular > > indexes. > > Hmm, why? Sounds strange to me to not have the same locking > semantics > for the partitioned parts, and this even if partitioned indexes don't > have stats that can be manipulated in relation_stats.c as far as I > can see. These stats APIs are designed to be permissive as Jeff > says. > Having a better locking from the start makes the whole picture more > consistent, while opening the door for actually setting real stat > numbers for partitioned indexes (if some make sense, at some point)? v45-0001 addresses this by locking both the partitioned index, as well as its table, in ShareUpdateExclusive mode. That satisfies the in-place update requirement to take a ShareUpdateExclusiveLock on the partitioned index, while otherwise being the same as normal indexes (and therefore unlikely to cause a problem if ANALYZE sets stats on partitioned indexes in the future). That means: *=C2=A0For indexes: ShareUpdateExclusiveLock on table and AccessShareLock on index * For partitioned indexes: ShareUpdateExclusiveLock on table and ShareUpdateExclusiveLock on index * Otherwise, ShareupdateExclusiveLock on the relation which makes sense to me. The v45-0001 patch itself could use some cleanup, but I can take care of that at commit time if we agree on the locking scheme. Regards, Jeff Davis