Re: PoC/WIP: Extended statistics on expressions
Justin Pryzby <pryzby@telsasoft.com>
From: Justin Pryzby <pryzby@telsasoft.com>
To: Tomas Vondra <tomas.vondra@enterprisedb.com>
Cc: Dean Rasheed <dean.a.rasheed@gmail.com>, pgsql-hackers@postgresql.org
Date: 2021-01-08T02:35:37Z
Lists: pgsql-hackers
On Fri, Jan 08, 2021 at 01:57:29AM +0100, Tomas Vondra wrote:
> Attached is a patch fixing most of the issues. There are a couple
> exceptions:
In the docs:
+ — at the cost that its schema must be extended whenever the structure
+ of statistics <link linkend="catalog-pg-statistic"><structname>pg_statistic</structname></link> changes.
should say "of statistics *IN* pg_statistics changes" ?
+ to an expression index. The full variant allows defining statistics objects
+ on multiple columns and expressions, and pick which statistics kinds will
+ be built. The per-expression statistics are built automatically when there
"and pick" is wrong - maybe say "and selecting which.."
+ and run a query using an expression on that column. Without the
remove "the" ?
+ extended statistics, the planner has no information about data
+ distribution for reasults of those expression, and uses default
*results
+ estimates as illustrated by the first query. The planner also does
+ not realize the value of the second column fully defines the value
+ of the other column, because date truncated to day still identifies
+ the month). Then expression and ndistinct statistics are built on
The ")" is unbalanced
+ /* all parts of thi expression are covered by this statistics */
this
+ * GrouExprInfos, but only if it's not known equal to any of the existing
Group
+ * we don't allow specifying any statistis kinds. The simple variant
statistics
+ * If no statistic type was specified, build them all (but request
Say "kind" not "type" ?
+ * expression is a simple Var. OTOH we check that there's at least one
+ * statistics matching the expression.
one statistic (singular) ?
+ * the future, we might consider
+ */
consider ???
+-- (not it fails, when there are no simple column references)
note?
There's some remaining copy/paste stuff from index expressions:
errmsg("statistics expressions and predicates can refer only to the table being indexed")));
left behind by evaluating the predicate or index expressions.
Set up for predicate or expression evaluation
Need an EState for evaluation of index expressions and
/* Compute and save index expression values */
left behind by evaluating the predicate or index expressions.
Fetch function for analyzing index expressions.
partial-index predicates. Create it in the per-index context to be
* When analyzing an expression index, believe the expression tree's type
--
Justin
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