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 1sZm2C-003f3k-6Z for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Aug 2024 06:45:04 +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 1sZm29-00FZwy-Jc for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Aug 2024 06:45:01 +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 1sZm29-00FZwn-1s for pgsql-hackers@lists.postgresql.org; Fri, 02 Aug 2024 06:45:01 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sZm26-002fev-6m for pgsql-hackers@lists.postgresql.org; Fri, 02 Aug 2024 06:44:59 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1fec34f94abso62599195ad.2 for ; Thu, 01 Aug 2024 23:44:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1722581097; x=1723185897; 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=mqIPkk5wvQoEl7vsa52jvy5rsK/aPfWzBmP1QysbmF8=; b=aMFv40QyLxTVdUc/d0n+1DGHxszNNILtmgb/zIhLwfqpCEkdCfW4xbuDoP8FmcMxhh UcoA/d/XJzi2ykcOzXans3nNAN9edAyHvfPoafbvsJBV4tHRd6Heuty8wJ9AS/jN+aSb ld4Z36Ba20uwu6uKVAY+AUcYW7bUEeAs9lYmPqnEEqlODKIY5OixcJ5QMufZQO2DT1sa d758kxD1N+vkG9JOh69eq15t8ctjmZ0o2J811HGOjIMa+X3r4vBBld4RCRRFScCuihxP g2CMJzOozfb/5iOIe6siy9oas8kqIJBUZkxGCw3R6I6de4ncGPON24tNBC731woUxv1C Id1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722581097; x=1723185897; 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=mqIPkk5wvQoEl7vsa52jvy5rsK/aPfWzBmP1QysbmF8=; b=prBaXQfUwyyLnMBA8gydu5d/o+H7dlUrof6Rif46dddOhIwTXJVUmyj77vo5ana8fv 5/VVyPTRKMVd3YD/v5zoYj5Gjpb74WvVTTsJ2+XQx/5ynzsgeY3D80fHPADjDrI05z3e swn18p9h/DkQcZk8RqkDIgYL470/XTivQUmvoXTN1CJxY3HC1Gbb3L3k9qsPblL5wzRN c1GGnhjJaPONtyaNnjJVRRn8wVZKHkpVKvniA7K/Z6rlUNcMGKC/KkzsmNq4f/yWFlIo +S+o8KtO9oq38GwfdFC1WtoFnWvsigvo8r7DsdHCMg69nili3q9VxuYaoyNgPoeMjYeI QTTQ== X-Forwarded-Encrypted: i=1; AJvYcCVxmbwLUK0UNWmDJNUpfYshKqg5rg3HILe7Hq0bLV1MTOGYM2zL9C1hUlyG/XQi/1FusOy0ygZaVpJqMElbpwbNt5rU2fHz2Fgj5Dio0knGdG01 X-Gm-Message-State: AOJu0YxrdiHIS7KdrbRQJgjBUCX4Xqav1HquZ9tCq0/kO9URj1fEFZaq 4GYLb3Op1ULXPAYdfZ5A8YTJf4cF0qJgK4FfruhAbhGovub7ZvGL2PuQPwhydA== X-Google-Smtp-Source: AGHT+IEU5dmwSdTXOmttMc3xV3N05501KH8yWzdKTxcSm6vczHd7HRcnUps8TlAv8hY4yOJkFFamLA== X-Received: by 2002:a17:902:d4c3:b0:1fd:a412:5e05 with SMTP id d9443c01a7336-1ff5744b23dmr36652195ad.52.1722581096720; Thu, 01 Aug 2024 23:44:56 -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 d9443c01a7336-1ff58f53efcsm9801745ad.82.2024.08.01.23.44.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 23:44:56 -0700 (PDT) Message-ID: 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: Thu, 01 Aug 2024 23:44:54 -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> <85eaf260a4be2e08376145a9d6a69d9d74e89daa.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 Sat, 2024-07-27 at 21:08 -0400, Corey Huinker wrote: >=20 > > I don't like the idea of mixing statistics and control parameters > > in > > the same list. > >=20 >=20 >=20 > There's no way around it, at least now we need never worry about a > confusing order for the parameters in the _restore_ functions because > they can now be in any order you like. Perhaps I was not precise enough when I said "control" parameters. Mainly what I was worried about is trying to take parameters that control things like transaction behavior (in-place vs mvcc), and pg_dump should not be specifying that kind of thing. A parameter like "version" is specified by pg_dump anyway, so it's probably fine the way you've done it. > SELECT pg_catalog.pg_set_attribute_stats( > =C2=A0 =C2=A0 relation =3D> 'stats_import.test'::regclass::oid, > =C2=A0 =C2=A0 attname =3D> 'arange'::name, > =C2=A0 =C2=A0 inherited =3D> false::boolean, > =C2=A0 =C2=A0 null_frac =3D> 0.5::real, > =C2=A0 =C2=A0 avg_width =3D> 2::integer, > =C2=A0 =C2=A0 n_distinct =3D> -0.1::real, > =C2=A0 =C2=A0 range_empty_frac =3D> 0.5::real, > =C2=A0 =C2=A0 range_length_histogram =3D> '{399,499,Infinity}'::text > =C2=A0 =C2=A0 ); > =C2=A0pg_set_attribute_stats=20 > ------------------------ > =C2=A0 > (1 row) I like it. > and here is a restore function >=20 > -- warning: mcv cast failure > SELECT * > FROM pg_catalog.pg_restore_attribute_stats( > =C2=A0 =C2=A0 'relation', 'stats_import.test'::regclass::oid, > =C2=A0 =C2=A0 'attname', 'id'::name, > =C2=A0 =C2=A0 'inherited', false::boolean, > =C2=A0 =C2=A0 'version', 150000::integer, > =C2=A0 =C2=A0 'null_frac', 0.5::real, > =C2=A0 =C2=A0 'avg_width', 2::integer, > =C2=A0 =C2=A0 'n_distinct', -0.4::real, > =C2=A0 =C2=A0 'most_common_vals', '{2,four,3}'::text, > =C2=A0 =C2=A0 'most_common_freqs', '{0.3,0.25,0.05}'::real[] > =C2=A0 =C2=A0 ); > WARNING: =C2=A0invalid input syntax for type integer: "four" > =C2=A0row_written | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0stats_applied =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 > =C2=A0stats_rejected =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| params_re= jected=20 > -------------+----------------------------------+-------------------- > ------------------+----------------- > =C2=A0t =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | {null_frac,avg_width,n_disti= nct} | > {most_common_vals,most_common_freqs} |=20 > (1 row) I think I like this, as well, except for the return value, which seems like too much information and a bit over-engineered. Can we simplify it to what's actually going to be used by pg_upgrade and other tools? > Attached is v25. I believe 0001 and 0002 are in good shape API-wise, and I can start getting those committed. I will try to clean up the code in the process. Regards, Jeff Davis