-- -- Test that restrictions that are always true are ignored, and that are always -- false are replaced with constant-FALSE -- -- Currently we only check for NullTest quals and OR clauses that include -- NullTest quals. We may extend it in the future. -- CREATETABLE pred_tab (a intNOTNULL, b int, c intNOTNULL);
-- -- Test restriction clauses --
-- Ensure the IS_NOT_NULL qual is ignored when the column is non-nullable EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t WHERE t.a ISNOTNULL;
-- Ensure the IS_NOT_NULL qual is not ignored on a nullable column EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t WHERE t.b ISNOTNULL;
-- Ensure the IS_NULL qual is reduced to constant-FALSE for non-nullable -- columns EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t WHERE t.a ISNULL;
-- Ensure the IS_NULL qual is not reduced to constant-FALSE on nullable -- columns EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t WHERE t.b ISNULL;
-- -- Tests for OR clauses in restriction clauses --
-- Ensure the OR clause is ignored when an OR branch is always true EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t WHERE t.a ISNOTNULLOR t.b = 1;
-- Ensure the OR clause is not ignored for NullTests that can't be proven -- always true EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t WHERE t.b ISNOTNULLOR t.a = 1;
-- Ensure the OR clause is reduced to constant-FALSE when all branches are -- provably false EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t WHERE t.a ISNULLOR t.c ISNULL;
-- Ensure the OR clause is not reduced to constant-FALSE when not all branches -- are provably false EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t WHERE t.b ISNULLOR t.c ISNULL;
-- -- Test join clauses --
-- Ensure the IS_NOT_NULL qual is ignored, since a) it's on a NOT NULL column, -- and b) its Var is not nullable by any outer joins EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 LEFTJOIN pred_tab t2 ON t1.a ISNOTNULL;
-- Ensure the IS_NOT_NULL qual is not ignored when columns are made nullable -- by an outer join EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1
FULL JOIN pred_tab t2 ON t1.a = t2.a LEFTJOIN pred_tab t3 ON t2.a ISNOTNULL;
-- Ensure the IS_NULL qual is reduced to constant-FALSE, since a) it's on a NOT -- NULL column, and b) its Var is not nullable by any outer joins EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 LEFTJOIN pred_tab t2 ON t1.a ISNULL;
-- Ensure the IS_NULL qual is not reduced to constant-FALSE when the column is -- nullable by an outer join EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 LEFTJOIN pred_tab t2 ON t1.a = 1 LEFTJOIN pred_tab t3 ON t2.a ISNULL;
-- -- Tests for OR clauses in join clauses --
-- Ensure the OR clause is ignored when an OR branch is provably always true EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 LEFTJOIN pred_tab t2 ON t1.a ISNOTNULLOR t2.b = 1;
-- Ensure the NullTest is not ignored when the column is nullable by an outer -- join EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1
FULL JOIN pred_tab t2 ON t1.a = t2.a LEFTJOIN pred_tab t3 ON t2.a ISNOTNULLOR t2.b = 1;
-- Ensure the OR clause is reduced to constant-FALSE when all OR branches are -- provably false EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 LEFTJOIN pred_tab t2 ON (t1.a ISNULLOR t1.c ISNULL);
-- Ensure the OR clause is not reduced to constant-FALSE when a column is -- made nullable from an outer join EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 LEFTJOIN pred_tab t2 ON t1.a = 1 LEFTJOIN pred_tab t3 ON t2.a ISNULLOR t2.c ISNULL;
DROPTABLE pred_tab;
-- Validate we handle IS NULL and IS NOT NULL quals correctly with inheritance -- parents. CREATETABLE pred_parent (a int); CREATETABLE pred_child () INHERITS (pred_parent); ALTERTABLE ONLY pred_parent ALTER a SETNOTNULL;
-- Ensure that the scan on pred_child contains the IS NOT NULL qual. EXPLAIN (COSTS OFF) SELECT * FROM pred_parent WHERE a ISNOTNULL;
-- Ensure we only scan pred_child and not pred_parent EXPLAIN (COSTS OFF) SELECT * FROM pred_parent WHERE a ISNULL;
ALTERTABLE pred_parent ALTER a DROPNOTNULL; ALTERTABLE pred_child ALTER a SETNOTNULL;
-- Ensure the IS NOT NULL qual is removed from the pred_child scan. EXPLAIN (COSTS OFF) SELECT * FROM pred_parent WHERE a ISNOTNULL;
-- Ensure we only scan pred_parent and not pred_child EXPLAIN (COSTS OFF) SELECT * FROM pred_parent WHERE a ISNULL;
DROPTABLE pred_parent, pred_child;
-- Validate we do not reduce a clone clause to a constant true or false CREATETABLE pred_tab (a int, b int); CREATETABLE pred_tab_notnull (a int, b intNOTNULL);
-- Ensure the IS_NOT_NULL qual is not reduced to constant true and removed EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 LEFTJOIN pred_tab t2 ONTRUE LEFTJOIN pred_tab_notnull t3 ON t2.a = t3.a LEFTJOIN pred_tab t4 ON t3.b ISNOTNULL;
SELECT * FROM pred_tab t1 LEFTJOIN pred_tab t2 ONTRUE LEFTJOIN pred_tab_notnull t3 ON t2.a = t3.a LEFTJOIN pred_tab t4 ON t3.b ISNOTNULL;
-- Ensure the IS_NULL qual is not reduced to constant false EXPLAIN (COSTS OFF) SELECT * FROM pred_tab t1 LEFTJOIN pred_tab t2 ONTRUE LEFTJOIN pred_tab_notnull t3 ON t2.a = t3.a LEFTJOIN pred_tab t4 ON t3.b ISNULLAND t3.a ISNOTNULL;
SELECT * FROM pred_tab t1 LEFTJOIN pred_tab t2 ONTRUE LEFTJOIN pred_tab_notnull t3 ON t2.a = t3.a LEFTJOIN pred_tab t4 ON t3.b ISNULLAND t3.a ISNOTNULL;
DROPTABLE pred_tab; DROPTABLE pred_tab_notnull;
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.0 Sekunden
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.