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 1tmdPj-008Ih4-KR for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Feb 2025 18:42:48 +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 1tmdPi-006L9o-Sg for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Feb 2025 18:42:46 +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 1tmdPi-006L8W-E5 for pgsql-hackers@lists.postgresql.org; Mon, 24 Feb 2025 18:42:46 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tmdPf-000WYT-0B for pgsql-hackers@lists.postgresql.org; Mon, 24 Feb 2025 18:42:45 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-22128b7d587so92159845ad.3 for ; Mon, 24 Feb 2025 10:42:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1740422563; x=1741027363; 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=9jpz5bzDwt4NrAMqr7Cmha35lnpXCR47uEHgNmGIAaw=; b=ggDpdvZPQeh12pBy1sJjRT94ab1vjsYQKFecIQP/xBSgVdxh80jym8FCwl5eVv5Q9P hALgyYcrSNlrH+wQT5fiPKALg/pKbTN14QL8GHl4qKR+SRwSTYc78/+qkdvoCEKPpWXD vz9GtPzpn2lhIUUQ3rvRR9lbYkE5L01+NV7EoinU1OeuB+aJkElmHJ2YnudmfUZPhdJ9 74avaJyQmVMGnNvQTan/i/QuK4FwqbzkI+O//uSJu8lJo4lEDr+FxNtyoYi0ck/4srPw 9hHLFJObTorv0IUC22AOKdztp4X/sIjlr/Fl+JyhML1aSMBumjjfxJ/iLHCi60DrP9P7 R/Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740422563; x=1741027363; 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=9jpz5bzDwt4NrAMqr7Cmha35lnpXCR47uEHgNmGIAaw=; b=IO/NQkr7pWti1lbr2Pzv2Nl6pqtEpcScCd5EhidZgcT16reLTBQyjaFQnVNVeWenzt fCWhxmj1ZzDxGty7BtS/rMu2NOguA3/VWvXuaDSXct8F+EeEWbdorIwITPXIADOinVF3 Qy9di60r/AiyRjPR9yPYCWqWWptj4vHP9NP6a/ZURJe4qZ2oRWBDi4EBP+IEEVmGBHrX uOMnrTDKtPF9vJ+0eUujjkqMOFMfOTbnfgM9Ebf1+ufyEQ4R/00k008uGcHK8e+dUZLq NsfLuqwdb9H8OGam6FdD4EbF5mz6Fc0wMPeSgHdDQ//kJ26SF2k8CQgK+2sIfF4QvBtF EouA== X-Forwarded-Encrypted: i=1; AJvYcCV1W9dqJqduG89ej9lnJ7HR6P2xw280XeA8elGo7IELldgJd/CVsJ5Q7lIanzLLR6sPIw22+h7umB23Ryi6@lists.postgresql.org X-Gm-Message-State: AOJu0YwtvYdBI1OablF+e40bLVhjzKMndOu7i5W2Tz0V3KQv/jyG4dsN N3Hu1//fQP+R5pHB5sgtb1M+aff0tT+5Ky890qkPUCB2ZSZIEl8tU1hyZVzMOg== X-Gm-Gg: ASbGncvjswt2XWeHKB9EwASk8GbqC1FURr4MaS1j7F7MJKHXSMVHwdxk/slAnNzsugb jO80emoNtj0HLszUyzZ2UcD17EgtOCqdWnKI2J0SNrpykRdlEaBBi5t5eHlghISOSfv0g+YHqQ/ wTDdt13m0GsrG6rbe9xTfdytywyp/vIpLUwt+u+CdmpiTAYixdWKCHQ36+sY+vH/YRKmH/HM3CK 88p2CG+5ByCngJFcslJwRjb2snQBXIsZza+7UyBgtmfPlhLERnkHOZA8d4tDkzcflg5isJ9kLcc QLXNmElT3z8abY5B5KOgRyxks4IH1ulG0fUQG9T7Rk6PtmTy4dyHU/JxihiHAHrzsY+m X-Google-Smtp-Source: AGHT+IGn0ajhpoWBisKVhye9/SOU4loixL+AX1UZwmC5Bfv7rKALvQC1+sXBmscmnGEdf+MY0m+oGQ== X-Received: by 2002:a05:6a21:9014:b0:1e1:ab8b:dda1 with SMTP id adf61e73a8af0-1eef3dca4a5mr26639073637.35.1740422562809; Mon, 24 Feb 2025 10:42:42 -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-73440ea9381sm4704213b3a.157.2025.02.24.10.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2025 10:42:42 -0800 (PST) Message-ID: Subject: Re: Statistics Import and Export From: Jeff Davis To: Tom Lane , Andres Freund Cc: Corey Huinker , Michael Paquier , jian he , Nathan Bossart , Bruce Momjian , Matthias van de Meent , Magnus Hagander , Stephen Frost , Ashutosh Bapat , Peter Smith , PostgreSQL Hackers , alvherre@alvh.no-ip.org Date: Mon, 24 Feb 2025 10:42:40 -0800 In-Reply-To: <1457469.1740419458@sss.pgh.pa.us> References: <3670503.1740173078@sss.pgh.pa.us> <3728741.1740178078@sss.pgh.pa.us> <97b451228227c555be1a4f79c4a62ddec9a74f06.camel@j-davis.com> <1457469.1740419458@sss.pgh.pa.us> 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 Mon, 2025-02-24 at 12:50 -0500, Tom Lane wrote: > Also, while working on the attached, I couldn't help forming the > opinion that we'd be better off to nuke pg_set_attribute_stats() > from orbit and require people to use pg_restore_attribute_stats(). I had intended the pg_set variants to be useful for ad-hoc stats hacking (e.g. for reproducing a plan or for testing the optimizer). For those use cases, the following differences seem nice: 1.=C2=A0named arguments are easier to write ad-hoc than lining up the parameters in pairs 2. elevel=3DERROR makes more sense than WARNING for that kind of use case. 3. for relation stats, we don't want in-place updates, because you want ROLLBACK to work Those seemed different enough from the restore case that another entry point made sense to me. > pg_set_attribute_stats() would be fine if we had a way to force > people to call it with only named-argument notation, but we don't. > So I'm afraid that its existence will encourage people to rely > on a specific parameter order, and then they'll whine if we > add/remove/reorder parameters, as indeed I had to do below. That's a good point that I hadn't considered, so perhaps we can't solve problem #1. The other two problems might be solvable though: * To avoid in-place updates I think we do need a separate function, at least for relation stats (attribute stats never do in-place updates). We could potentially have another name/value pair to choose, but it's impossible to choose a reasonable default: if "inplace" is the default, that means the user would need to opt-out of it for ROLLBACK to work; if "mvcc" is the default, that means pg_dump would need to choose "inplace", and I don't think pg_dump should be making those kinds of decisions. * The elevel=3DERROR is not terribly important, so perhaps we can just always do elevel=3DWARNING. If we did try to present it as an option, then that presents the same problems as an "inplace" option. So perhaps we can just have the pg_set variants set elevel=3DERROR and inplace=3Dfalse, and otherwise be identical to the pg_restore variants? Regards, Jeff Davis