[COMMITTERS] pgsql: Fix <> and pattern-NOT-match estimators to handle nullscorrectl

Поиск
Список
Период
Сортировка
От Tom Lane
Тема [COMMITTERS] pgsql: Fix <> and pattern-NOT-match estimators to handle nullscorrectl
Дата
Msg-id E1dHDuc-0008Vy-T2@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix <> and pattern-NOT-match estimators to handle nulls correctly.

These estimators returned 1 minus the corresponding equality/match
estimate, which is incorrect: we need to subtract off the fraction
of nulls in the column, since those are neither equal nor not equal
to the comparison value.  The error only becomes obvious if the
nullfrac is large, but it could be very bad in a mostly-nulls
column, as reported in bug #14676 from Marko Tiikkaja.

To fix the <> case, refactor eqsel() and neqsel() to call a common
support routine, which can be made to account for nullfrac correctly.
The pattern-match cases were already factored that way, and it was
simply an oversight that patternsel() wasn't subtracting off nullfrac.

neqjoinsel() has a similar problem, but since we're elsewhere discussing
changing its behavior entirely, I left it alone for now.

This is a very longstanding bug, but I'm hesitant to back-patch a fix for
it.  Given the lack of prior complaints, such cases must not come up often,
so it's probably not worth the risk of destabilizing plans in stable
branches.

Discussion: https://postgr.es/m/20170529153847.4275.95416@wrigleys.postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/512c7356b6574e7622fddb713f96dc8407960680

Modified Files
--------------
src/backend/utils/adt/selfuncs.c | 163 +++++++++++++++++++++++++--------------
1 file changed, 103 insertions(+), 60 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: [COMMITTERS] pgsql: Fix old corner-case logic error in final_cost_nestloop().
Следующее
От: Tom Lane
Дата:
Сообщение: [COMMITTERS] pgsql: Add some missing backslash commands to psql's tab-completionkno