Skip to content

Fold not-null tests in index expressions and predicates - #1624

Merged
tamnd merged 2 commits into
mainfrom
index-null-reduce
Nov 19, 2026
Merged

tamnd merged 2 commits into
mainfrom
index-null-reduce

Conversation

@tamnd

@tamnd tamnd commented Nov 19, 2026

Copy link
Copy Markdown
Owner

get_relation_info runs eval_const_expressions on the index expressions and the predicate again with the planner's root, so a NullTest of a column in notnullattnums reduces to a constant. rupg folded them with an empty query, so the tests stayed and the indexes of predicate.sql (pred_tab_exprs_idx, pred_tab_pred_idx) were not used.

  • indexes in connection/explain.rs replaces IS [NOT] NULL of a column with a valid not-null constraint (not a row type) by true/false before the fold.
  • A predicate that folds to true is dropped, and partial now follows the folded predicate, as indpred becomes NIL in PostgreSQL.

Test index_null_reduce: the fixture is the output of PostgreSQL 19 for the same script (expression index, predicate index, WHERE b IS NULL on a not-null column, and a nullable column whose test stays).

btcost_correlation of an index whose first key is an expression now reads the correlation from the statistics of the index, as examine_indexcol_variable does; rupg read only table columns, so such an index scan cost twice PostgreSQL's (16.22 against 8.60) and lost to a bitmap scan.

@tamnd tamnd added this to the M7: Procedures milestone Nov 19, 2026
@tamnd tamnd added kind/feature It does not do something that it must do. area/execution Operators, vectors, morsels, joins, aggregation and spill. labels Nov 19, 2026
@tamnd
tamnd merged commit f82a247 into main Nov 19, 2026
@tamnd
tamnd deleted the index-null-reduce branch November 19, 2026 02:22
@tamnd tamnd mentioned this pull request Nov 19, 2026
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/execution Operators, vectors, morsels, joins, aggregation and spill. kind/feature It does not do something that it must do.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant