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 1qyY7c-00976Q-6z for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Nov 2023 13:52:32 +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 1qyY7Z-00DJu1-W2 for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Nov 2023 13:52:29 +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 1qyY7Z-00DJtq-LC for pgsql-hackers@lists.postgresql.org; Thu, 02 Nov 2023 13:52:29 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qyY7W-004KnW-54 for pgsql-hackers@lists.postgresql.org; Thu, 02 Nov 2023 13:52:28 +0000 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-99357737980so144882666b.2 for ; Thu, 02 Nov 2023 06:52:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1698933142; x=1699537942; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=zIPEzlg5DKTVpxZ50ufgw4R1V3NptcDdXOYzP4TQl0w=; b=gpOGIz6EDWXOSBsqqcCle1VSvMKPMk3YL11R8ztNZtKixmW99MeJ53Hzvx/vkSIp+Q 7OVmtJmjppEYegaw3r19CZ8tM6kRNIZnSQYexv8Rc5LKaqapmQRBQK8nsy7oXf5kNUBI eRr311aIaXnW+WXxnImz5vJ6dasTohxoS5eDYkxPotlBtUKkEv+RtjQL8tvVBmkqWoGU 4CpPzMgJQHyObns+zly+1vWpFHl+fr/cLt2gNDQZh4JsVcx2KQW8RfbHNsjJOpmqHZB1 STGRe6FFRVZwPJcSIpJf/dwqXQu4tRyYQrVxJRtJ2f0Y/uvTTk4zmsoSA8Y4OvL2zcdN Y9XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698933142; x=1699537942; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zIPEzlg5DKTVpxZ50ufgw4R1V3NptcDdXOYzP4TQl0w=; b=CX3lDmkcJDzoaKlQzhEz7yISHa4mzWjHjPyNEr4o/LvN0e/PWpFbM0P7wU07CC9lA6 lcg1LHrKhev6DiPJeJgiNoOPvaCUTvL6/g6doFHp7XP3bABP/y5G2Vui6gn6AEZjP5iy OOrgd9i0imXZFszh/cx0sf+LCnQ5QUMbd0V7I18kG/96NCq9g17QxnpNtmCLeA4i96w8 E5eafRfNDufnhKHOk6V/9004OcR5W8YltCRsRAFhy2pG5bbZ6jehq0nwFGTWp9IrUi1Y sAiGTDHyjbzmAkSyQcXkQjQFgylBiUKl1dk6D5W0sp/QudX6QKRNC+jvBkYE2FetWJL6 MeEg== X-Gm-Message-State: AOJu0Yxm0HwTr9fqJ57XOgK34Et6wIpEbae5z9mgCrPc7HP6nqziM9PE 6SKQ4FY8wzMjtWc/iD5O8xK/MQ== X-Google-Smtp-Source: AGHT+IEgh+ufwiNX3+sa883Zvp/mcgqNOQlRk4Jtp30mkiLS1A1wrqP6/WLfVEaTGulpsXh/ZccV5A== X-Received: by 2002:a17:906:eece:b0:9c7:5a14:ecf2 with SMTP id wu14-20020a170906eece00b009c75a14ecf2mr4662723ejb.56.1698933142565; Thu, 02 Nov 2023 06:52:22 -0700 (PDT) Received: from [10.137.0.17] (srv1.mobissw.com. [89.235.0.226]) by smtp.gmail.com with ESMTPSA id x20-20020a1709065ad400b009d0be9be6e2sm1151542ejs.43.2023.11.02.06.52.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Nov 2023 06:52:21 -0700 (PDT) Message-ID: <76596388-6fe6-0baf-351d-734458a46d76@enterprisedb.com> Date: Thu, 2 Nov 2023 14:52:20 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: Statistics Import and Export To: Corey Huinker Cc: Ashutosh Bapat , pgsql-hackers@lists.postgresql.org References: Content-Language: en-US From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/2/23 06:01, Corey Huinker wrote: > > > Maybe I just don't understand, but I'm pretty sure ANALYZE does not > derive index stats from column stats. It actually builds them from the > row sample. > > > That is correct, my error. >   > > > > * now support extended statistics except for MCV, which is currently > > serialized as an difficult-to-decompose bytea field. > > Doesn't pg_mcv_list_items() already do all the heavy work? > > > Thanks! I'll look into that. > > The comment below in mcv.c made me think there was no easy way to get > output. > > /* >  * pg_mcv_list_out      - output routine for type pg_mcv_list. >  * >  * MCV lists are serialized into a bytea value, so we simply call byteaout() >  * to serialize the value into text. But it'd be nice to serialize that into >  * a meaningful representation (e.g. for inspection by people). >  * >  * XXX This should probably return something meaningful, similar to what >  * pg_dependencies_out does. Not sure how to deal with the deduplicated >  * values, though - do we want to expand that or not? >  */ > Yeah, that was the simplest output function possible, it didn't seem worth it to implement something more advanced. pg_mcv_list_items() is more convenient for most needs, but it's quite far from the on-disk representation. That's actually a good question - how closely should the exported data be to the on-disk format? I'd say we should keep it abstract, not tied to the details of the on-disk format (which might easily change between versions). I'm a bit confused about the JSON schema used in pg_statistic_export view, though. It simply serializes stakinds, stavalues, stanumbers into arrays ... which works, but why not to use the JSON nesting? I mean, there could be a nested document for histogram, MCV, ... with just the correct fields. { ... histogram : { stavalues: [...] }, mcv : { stavalues: [...], stanumbers: [...] }, ... } and so on. Also, what does TRIVIAL stand for? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company