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 1sW3fE-00D2RA-Ar for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jul 2024 00:46:00 +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 1sW3fC-008Sn5-1O for pgsql-hackers@arkaria.postgresql.org; Tue, 23 Jul 2024 00:45:58 +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 1sW3fB-008Smx-Im for pgsql-hackers@lists.postgresql.org; Tue, 23 Jul 2024 00:45:58 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sW3f9-000yJK-AN for pgsql-hackers@lists.postgresql.org; Tue, 23 Jul 2024 00:45:57 +0000 Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2cb52e2cb33so2604429a91.0 for ; Mon, 22 Jul 2024 17:45:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1721695553; x=1722300353; 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=Op7v5dTGhfuPGFLIeT75D4U1BhOz9AHa7n6LtJO+i2U=; b=Lmnft3QD4PIK9NM9lI84kHii8IMbPG/Mv4KRl37VcqCrTXV0WXteYDPAXJyDP4cm/g rwDylCpteRnG9U4GE4g/RSwpCxf73ZsFaxl4/7kq5tyUK1FAK+zPHzUZInKuBJy7phAm j71Mqq6OGEhc7Er1RpN8Uz9Gfk4+af7+I/AiAUnDPS0oPTP2tKA7l5uQf/nyVvH3F1uU ChNbxcpaxvk9uSG36//Dj3SDUW4SbKabHN2m1oRSuTfW5nJTpUjbCLmqWShvKd8Igcry td5U6GcoFvEdXU1OHxvC9njty8WBlBGn7eOoQW7oMH0rsGZ/XaMtHdMeSdgNx22KNKiS ms0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721695553; x=1722300353; 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=Op7v5dTGhfuPGFLIeT75D4U1BhOz9AHa7n6LtJO+i2U=; b=dTYj1EPBf0MZiZYyd/1qfSJ7DSRd7v41Elm9A4+VoJ6ejm+zvHyg8lRtbalWqUQdN9 fqdEXNvRz0+aZy4JwyygRn5ix9XSUc5iS4h6pY4wAtJvS3qeNJhQRKNzFX2qcnAjBKwn LdQ2et8Tm7WWly5LXAp39AtIBzZVFMkPUDg0AOq6eAgDlxxjf/xkZPYkL+T3BNmvl2pc Se/XTxGoXBju0MvspLwJRzV+6U8YEc+J0LGXnThvvXofnINWfU8fMDdc7ugdAddYCJjd Ly+HLv4g/UGZbzpDhWb4F9qqMJW3Xf5QWH5+5jSHqZqQOJVVi7nxbf3kMEZKrtn/DTeT kvDg== X-Forwarded-Encrypted: i=1; AJvYcCWvQ0Z8PTcXIABreX+PUQIERdkmzjarZQ+WD8dY9ZG989ZiykRnOu1m8yhSNJpD7Q86o7RRpk+xeCSmkA7ucdoPjKME6agrYe6Iy8QTuMUAx5Zt X-Gm-Message-State: AOJu0YypoWiVIXjP0vj3nvz5eVpsPKJKvPnLOBbC1y4v9SjJyjnC29ea lbpyPkhVZTK+2AGGY6dG8zxuFpqjuit46iBfYd7NSDdNhMJjP7lhX5inADJP/Q== X-Google-Smtp-Source: AGHT+IGkAjlhVh2ttIWThgeXDyJVo/2UzNMIfUDdsfTxzSNKIyks22UX8JmZ48z59j8rKzFSo1odNA== X-Received: by 2002:a17:90b:1110:b0:2c8:da73:af82 with SMTP id 98e67ed59e1d1-2cd27412c23mr4730294a91.10.1721695552736; Mon, 22 Jul 2024 17:45:52 -0700 (PDT) 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 98e67ed59e1d1-2ccf808f082sm7659404a91.44.2024.07.22.17.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 17:45:52 -0700 (PDT) Message-ID: <85eaf260a4be2e08376145a9d6a69d9d74e89daa.camel@j-davis.com> Subject: Re: Statistics Import and Export From: Jeff Davis To: Corey Huinker Cc: Matthias van de Meent , Bruce Momjian , Tom Lane , Nathan Bossart , Magnus Hagander , Stephen Frost , Ashutosh Bapat , Peter Smith , PostgreSQL Hackers , Tomas Vondra , alvherre@alvh.no-ip.org Date: Mon, 22 Jul 2024 17:45:50 -0700 In-Reply-To: References: <1798867.1712376328@sss.pgh.pa.us> <20240417165053.GA3253364@nathanxps13> <0943da4616837682c65e4620050b8b1e86fe3503.camel@j-davis.com> <3156140.1713817153@sss.pgh.pa.us> <1d70aabacd379ed8f9a7db1bf4ca22d1f5cd943f.camel@j-davis.com> <3228677.1713844341@sss.pgh.pa.us> <10f251857a13cfc799079ba89d50b135c974a18e.camel@j-davis.com> <1a8ec76a863539ec2f849f247ee0e99dff8303e2.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 Mon, 2024-07-22 at 12:05 -0400, Corey Huinker wrote: > Attached is v24, incorporating Jeff's feedback - looping an arg data > structure rather than individually checking each param type being the > biggest of them. >=20 Thank you for splitting up the patches more finely. v24-0001: * pg_set_relation_stats(): the warning: "cannot export statistics prior to version 9.2" doesn't make sense because the function is for importing. Reword. * I really think there should be a transactional option, just another boolean, and if it has a default it should be true. This clearly has use cases for testing plans, etc., and often transactions will be the right thing there. This should be a trivial code change, and it will also be easier to document. * The return type is documented as 'void'? Please change to bool and be clear about what true/false returns really mean. I think false means "no updates happened at all, and a WARNING was printed indicating why" whereas true means "all updates were applied successfully". * An alternative would be to have an 'error_ok' parameter to say whether to issue WARNINGs or ERRORs. I think we already discussed that and agreed on the boolean return, but I just want to confirm that this was a conscious choice? * tests should be called stats_import.sql; there's no exporting going on * Aside from the above comments and some other cleanup, I think this is a simple patch and independently useful. I am looking to commit this one soon. v24-0002: * Documented return type is 'void' * I'm not totally sure what should be returned in the event that some updates were applied and some not. I'm inclined to say that true should mean that all updates were applied -- otherwise it's hard to automatically detect some kind of typo. * Can you describe your approach to error checking? What kinds of errors are worth checking, and which should we just put into the catalog and let the planner deal with? * I'd check stakindidx at the time that it's incremented rather than summing boolean values cast to integers. v24-0003: * I'm not convinced that we should continue when a stat name is not text. The argument for being lenient is that statistics may change over time, and we might have to ignore something that can't be imported from an old version into a new version because it's either gone or the meaning has changed too much. But that argument doesn't apply to a bogus call, where the name/value pairs get misaligned or something. Regards, Jeff Davis