Re: PoC/WIP: Extended statistics on expressions
Tomas Vondra <tomas.vondra@enterprisedb.com>
From: Tomas Vondra <tomas.vondra@enterprisedb.com>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: Justin Pryzby <pryzby@telsasoft.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2021-01-05T15:09:19Z
Lists: pgsql-hackers
On 1/5/21 3:10 PM, Dean Rasheed wrote: > On Tue, 5 Jan 2021 at 00:45, Tomas Vondra <tomas.vondra@enterprisedb.com> 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
Commits
-
Disallow extended statistics on system columns
- 66061077155d 14.0 landed
- c9eeef2a15c0 15.0 landed
-
Identify simple column references in extended statistics
- 50ba70a957f9 14.0 landed
- 537ca68dbb24 15.0 landed
-
Don't print extra parens around expressions in extended stats
- 4d1816ec26e8 14.0 landed
- 13380e147649 15.0 landed
-
Change position of field "transformed" in struct CreateStatsStmt.
- 13a1ca160dcf 14.0 landed
-
Add transformed flag to nodes/*funcs.c for CREATE STATISTICS
- d57ecebd128c 14.0 landed
-
Stabilize stats_ext test with other collations
- 2a058e938c73 14.0 landed
-
Extended statistics on expressions
- a4d75c86bf15 14.0 landed
-
Reduce duration of stats_ext regression tests
- 98376c18f12e 14.0 landed
-
Allow composite types in catalog bootstrap
- 79f6a942bdb9 14.0 landed
-
Convert Typ from array to list in bootstrap
- e1a5e65703ce 14.0 landed
-
Disallow CREATE STATISTICS on system catalogs
- c22539756ee5 10.16 landed
- f52db969440b 11.11 landed
- 943a113bcb6f 12.6 landed
- d26d4c717dbf 13.2 landed
- c9a0dc34865f 14.0 landed