Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kwnxh-0005sq-Jv for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Jan 2021 15:09:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kwnxf-0008F3-Iv for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Jan 2021 15:09:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kwnxf-0008Ew-5R for pgsql-hackers@lists.postgresql.org; Tue, 05 Jan 2021 15:09:27 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kwnxb-0000KR-Op for pgsql-hackers@postgresql.org; Tue, 05 Jan 2021 15:09:26 +0000 Received: by mail-ed1-x529.google.com with SMTP id u19so338435edx.2 for ; Tue, 05 Jan 2021 07:09:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=WP94bXZrMORI8cd+JIBmD46v1rBTQqE/DlabRxwsn28=; b=WPH6/XaN+lhmnS1qkgKicDH+EgTiq4JMBKMz2s3m8vcSqe/RiyOkYlyeXlVxGptjiJ DOWNLWnd1ACky5HLBBE0GSS6IdByeKeGb0B1f1VBoHuKCSKoJGlQbuNJ9zS/o6AeOSsj DWnhMgnlvVgHkZBkCSeKacHnRpTZuNOo+mV/v06oxs2vpB6aRMbEZX2FhScjII2nEM1p 5BdlJiKCso/HRAlDnl+dRti6S2lo8wOrqUqUrMHcUkpTpLaQO6zXviJ1TXb4g1XKXl8E dFPTBpofEePznLRoZEXP/PxNprwC20o3g82fnwxDOfH9JgCCLEgnEmeNrryZt4Y6bN5q aPXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=WP94bXZrMORI8cd+JIBmD46v1rBTQqE/DlabRxwsn28=; b=Cz+4pRXKoWioMwJ2s8IG0sSk8/G8DihNrBPEBAev5LHNFseu0qDWHgT8oW3kQ0k6wp SylGz6dkf4BNG6msLZ6XVVEAoAMXJSzZutHCBwmC1nxFZVTHDDH7RtcYlveyCtPvMPBL XXk5PrBXk3/OWlT+g8MK5j4xRQss5arPueuvu3WvzdUfhrBZKhpZksF9FGxzzCSHQ/2J q/b1x+LG1O3Cvvg4on8UAh3G/sxM9f7ejK/MOVXTetrA58kIsaG5wqF4alSIM4rIaulv glbxCl4krcClWVreCdBRVuCvKm+sJHwkTelTOuj9q4u4lVpl7FrKKovBqrj60PECvTFC iLhg== X-Gm-Message-State: AOAM533jJ1pG4CNI1h+AEkf0i5HSaBFv4xfVQ55g7ALd56Ns+mz2v+Nl 9miYwHui9y2ItrOIuLnFcqxbUfWrOphq4QrvIdQO0/XdBiYHn1M79rGo4mdeeOS4vxAhaEjxB78 QaIS11uW1Rua8pitfmwvXIFdk8BPbzL2NAuKk+VpxMSj3irf/H3Dz6/ho1iwnkbj9Gts59uOz3G 1dEsapG5uzHR6LSR7SzlrJzGQJVAm9ucyl9naIPm+lodrvIW98tzidhrmIWNxfI7Bmmpd90HjsW gcVrJ9GFTt0ot3+Oy0NVCoxRjvwN7C3w9EndogO1Ug= X-Google-Smtp-Source: ABdhPJwkoCa2evgxKywItdezz+FpZQ5j9qQXOxL20JQjoHXYu9k1WQs3ULC6jm9gVcG/Y679zyL5jw== X-Received: by 2002:a50:b586:: with SMTP id a6mr197505ede.206.1609859362059; Tue, 05 Jan 2021 07:09:22 -0800 (PST) Received: from [10.137.0.20] (ip-86-49-249-71.net.upcbroadband.cz. [86.49.249.71]) by smtp.gmail.com with ESMTPSA id n17sm24848904ejh.49.2021.01.05.07.09.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Jan 2021 07:09:21 -0800 (PST) Subject: Re: PoC/WIP: Extended statistics on expressions To: Dean Rasheed Cc: Justin Pryzby , pgsql-hackers References: <3fbbd68b-0b52-cb5a-d468-7e7280c33e6c@enterprisedb.com> <4654037b-8df8-77fb-2981-67be93aebdf1@enterprisedb.com> <20201123022604.GD24052@telsasoft.com> <6455e0ad-2a2e-bdb0-e1f8-fd4983d1c8aa@enterprisedb.com> <087086de-1384-8374-4efc-2e7915071d5c@enterprisedb.com> <4a2918bb-49b0-ccd5-3af7-f7795941a6ad@enterprisedb.com> <958870c8-65e0-31b1-4591-b0b10e807dd9@enterprisedb.com> <329203a4-7cad-a0e3-d5a8-ce70872c8156@enterprisedb.com> From: Tomas Vondra Message-ID: <2567ae7e-e1dd-48b5-054d-ed6ff81c0335@enterprisedb.com> Date: Tue, 5 Jan 2021 16:09:19 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/5/21 3:10 PM, Dean Rasheed wrote: > On Tue, 5 Jan 2021 at 00:45, Tomas Vondra wrote: >> >> On 1/4/21 4:34 PM, Dean Rasheed wrote: >>> >>> * In src/bin/psql/describe.c, I think the \d output should also >>> exclude the "expressions" stats kind and just list the other kinds (or >>> have no kinds list at all, if there are no other kinds), to make it >>> consistent with the CREATE STATISTICS syntax. >> >> Not sure I understand. Why would this make it consistent with CREATE >> STATISTICS? Can you elaborate? >> > > This isn't absolutely essential, but I think it would be neater. For > example, if I have a table with stats like this: > > CREATE TABLE foo(a int, b int); > CREATE STATISTICS foo_s_ab (mcv) ON a,b FROM foo; > > then the \d output is as follows: > > \d foo > Table "public.foo" > Column | Type | Collation | Nullable | Default > --------+---------+-----------+----------+--------- > a | integer | | | > b | integer | | | > Statistics objects: > "public"."foo_s_ab" (mcv) ON a, b FROM foo > > and the stats line matches the DDL used to create the stats. It could, > for example, be copy-pasted and tweaked to create similar stats on > another table, but even if that's not very likely, it's neat that it > reflects how the stats were created. > > OTOH, if there are expressions in the list, it produces something like this: > > Table "public.foo" > Column | Type | Collation | Nullable | Default > --------+---------+-----------+----------+--------- > a | integer | | | > b | integer | | | > Statistics objects: > "public"."foo_s_ab" (mcv, expressions) ON a, b, ((a * b)) FROM foo > > which no longer matches the DDL used, and isn't part of an accepted > syntax, so seems a bit inconsistent. > > In general, if we're making the "expressions" kind an internal > implementation detail that just gets built automatically when needed, > then I think we should hide it from this sort of output, so the list > of kinds matches the list that the user used when the stats were > created. > Hmm, I see. You're probably right it's not necessary to show this, given the modified handling of expression stats (which makes them an internal detail, not exposed to users). I'll tweak this. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company