postgresql/src/include/catalog
Tom Lane a80818605e Improve selectivity estimation for assorted match-style operators.
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 911e70207 just created new
versions of those extensions that we haven't released yet, we can sneak
this change into those new versions instead of having to create an
additional generation of update scripts.

Patch by me, reviewed by Alexey Bashtanov

Discussion: https://postgr.es/m/12237.1582833074@sss.pgh.pa.us
2020-04-01 10:32:33 -04:00
..
.gitignore Replace our traditional initial-catalog-data format with a better design. 2018-04-08 13:17:27 -04:00
Makefile Update copyrights for 2020 2020-01-01 12:21:45 -05:00
binary_upgrade.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
catalog.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
catversion.h Improve selectivity estimation for assorted match-style operators. 2020-04-01 10:32:33 -04:00
dependency.h Avoid duplicates in ALTER ... DEPENDS ON EXTENSION 2020-03-11 11:04:59 -03:00
duplicate_oids Update copyrights for 2020 2020-01-01 12:21:45 -05:00
genbki.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
heap.h Implement operator class parameters 2020-03-30 19:17:23 +03:00
index.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
indexing.h Invent "trusted" extensions, and remove the pg_pltemplate catalog. 2020-01-29 18:42:43 -05:00
namespace.h Improve performance of "simple expressions" in PL/pgSQL. 2020-03-26 18:58:57 -04:00
objectaccess.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
objectaddress.h Remove utils/acl.h from catalog/objectaddress.h 2020-03-10 10:27:00 +01:00
opfam_internal.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
partition.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_aggregate.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_aggregate.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_am.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_am.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_amop.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_amop.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_amproc.dat Implement operator class parameters 2020-03-30 19:17:23 +03:00
pg_amproc.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_attrdef.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_attribute.h Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
pg_auth_members.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_authid.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_authid.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_cast.dat Implement type regcollation 2020-03-18 21:21:00 +01:00
pg_cast.h Split out CreateCast into src/backend/catalog/pg_cast.c 2020-03-10 11:28:23 -03:00
pg_class.dat Don't require pg_class.dat to contain correct relnatts values. 2020-02-15 14:57:27 -05:00
pg_class.h Don't require pg_class.dat to contain correct relnatts values. 2020-02-15 14:57:27 -05:00
pg_collation.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_collation.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_constraint.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_control.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_conversion.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_conversion.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_database.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_database.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_db_role_setting.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_default_acl.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_depend.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_description.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_enum.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_event_trigger.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_extension.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_foreign_data_wrapper.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_foreign_server.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_foreign_table.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_index.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_inherits.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_init_privs.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_language.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_language.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_largeobject.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_largeobject_metadata.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_namespace.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_namespace.h Remove utils/acl.h from catalog/objectaddress.h 2020-03-10 10:27:00 +01:00
pg_opclass.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_opclass.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_operator.dat Improve selectivity estimation for assorted match-style operators. 2020-04-01 10:32:33 -04:00
pg_operator.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_opfamily.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_opfamily.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_partitioned_table.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_policy.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_proc.dat Improve selectivity estimation for assorted match-style operators. 2020-04-01 10:32:33 -04:00
pg_proc.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_publication.h Support adding partitioned tables to publication 2020-03-10 09:09:32 +01:00
pg_publication_rel.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_range.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_range.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_replication_origin.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_rewrite.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_seclabel.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_sequence.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_shdepend.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_shdescription.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_shseclabel.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_statistic.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_statistic_ext.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_statistic_ext_data.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_subscription.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_subscription_rel.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_tablespace.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_tablespace.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_transform.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_trigger.h Record parents of triggers 2020-02-27 13:23:33 -03:00
pg_ts_config.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_ts_config.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_ts_config_map.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_ts_config_map.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_ts_dict.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_ts_dict.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_ts_parser.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_ts_parser.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_ts_template.dat Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_ts_template.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pg_type.dat Introduce "anycompatible" family of polymorphic types. 2020-03-19 11:43:11 -04:00
pg_type.h Introduce "anycompatible" family of polymorphic types. 2020-03-19 11:43:11 -04:00
pg_user_mapping.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
reformat_dat_file.pl Update copyrights for 2020 2020-01-01 12:21:45 -05:00
renumber_oids.pl Update copyrights for 2020 2020-01-01 12:21:45 -05:00
storage.h Revert "Skip WAL for new relfilenodes, under wal_level=minimal." 2020-03-22 09:24:09 -07:00
storage_xlog.h Update copyrights for 2020 2020-01-01 12:21:45 -05:00
toasting.h Invent "trusted" extensions, and remove the pg_pltemplate catalog. 2020-01-29 18:42:43 -05:00
unused_oids Update copyrights for 2020 2020-01-01 12:21:45 -05:00