mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-11-27 07:21:09 +08:00
a80818605e
Quite a few matching operators such as JSONB's @> used "contsel" and
"contjoinsel" as their selectivity estimators. That was a bad idea,
because (a) contsel is only a stub, yielding a fixed default estimate,
and (b) that default is 0.001, meaning we estimate these operators as
five times more selective than equality, which is surely pretty silly.
There's a good model for improving this in ltree's ltreeparentsel():
for any "var OP constant" query, we can try applying the operator
to all of the column's MCV and histogram values, taking the latter
as being a random sample of the non-MCV values. That code is
actually 100% generic, except for the question of exactly what
default selectivity ought to be plugged in when we don't have stats.
Hence, migrate the guts of ltreeparentsel() into the core code, provide
wrappers "matchingsel" and "matchingjoinsel" with a more-appropriate
default estimate, and use those for the non-geometric operators that
formerly used contsel (mostly JSONB containment operators and tsquery
matching).
Also apply this code to some match-like operators in hstore, ltree, and
pg_trgm, including the former users of ltreeparentsel as well as ones
that improperly used contsel. Since commit
|
||
---|---|---|
.. | ||
data | ||
expected | ||
sql | ||
.gitignore | ||
Makefile | ||
pg_trgm--1.0--1.1.sql | ||
pg_trgm--1.1--1.2.sql | ||
pg_trgm--1.2--1.3.sql | ||
pg_trgm--1.3--1.4.sql | ||
pg_trgm--1.3.sql | ||
pg_trgm--1.4--1.5.sql | ||
pg_trgm.control | ||
trgm_gin.c | ||
trgm_gist.c | ||
trgm_op.c | ||
trgm_regexp.c | ||
trgm.h |