Simplify pattern selectivity estimation. Remove a couple hundred lines of ancient code that purported to estimate the selectivity of LIKE and regex patterns. This code was fundamentally bogus in several ways: the estimation rules it used didn't have much foundation in reality, it could produce different results depending on database encoding, and its understanding of regex syntax was far short of adequate. Moreover, we don't really need it since we installed the histogram_selectivity() machinery: in just about all practical cases, we will get a far-more-trustworthy selectivity estimate by seeing how many of the histogram and MCV list entries match the pattern. So rip all that out, and just use DEFAULT_MATCH_SEL to represent the selectivity of the non-prefix part of the pattern when we don't have adequate statistics. (We keep the prefix-match logic, since we'd want that anyway to permit indexscan optimizations.)
This change requires rejiggering one set of tests in inherit.sql so that they continue to prove what they're supposed to about statistics being inaccessible to users without adequate permissions. The default selectivity of the regex operator is now small enough to cause the test query to be planned as a nestloop, so change the pattern to select a large fraction not a small fraction of the rows. This flips the choice between hash and nestloop plans, which is fine since the point is just to show that hiding the statistics matters. Author: Chengpeng Yan <[email protected]> Reviewed-by: Tom Lane <[email protected]> Discussion: https://postgr.es/m/[email protected] Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/31878ccc2cd5642a5d2a1a39dedb79e9a18c8a07 Modified Files -------------- src/backend/utils/adt/like_support.c | 298 +++------------------------------- src/test/regress/expected/inherit.out | 66 ++++---- src/test/regress/sql/inherit.sql | 10 +- 3 files changed, 63 insertions(+), 311 deletions(-)
