regression.diffs

text/plain

Filename: regression.diffs
Type: text/plain
Part: 0
Message: Re: POC, WIP: OR-clause support for indexes
diff -U3 /home/alena/postgrespro7/src/test/regress/expected/create_index.out /home/alena/postgrespro7/src/test/regress/results/create_index.out
--- /home/alena/postgrespro7/src/test/regress/expected/create_index.out	2023-06-27 10:20:52.287769054 +0300
+++ /home/alena/postgrespro7/src/test/regress/results/create_index.out	2023-06-27 10:32:20.701220051 +0300
@@ -1838,26 +1838,14 @@
 EXPLAIN (ANALYZE, COSTS OFF, BUFFERS, TIMING OFF, SUMMARY OFF)
 SELECT * FROM tenk1
   WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42);
-                                                               QUERY PLAN                                                                
------------------------------------------------------------------------------------------------------------------------------------------
- Bitmap Heap Scan on tenk1 (actual rows=1 loops=1)
-   Recheck Cond: (((thousand = 42) AND (tenthous = 1)) OR ((thousand = 42) AND (tenthous = 3)) OR ((thousand = 42) AND (tenthous = 42)))
-   Heap Blocks: exact=1
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
+ Index Scan using tenk1_thous_tenthous on tenk1 (actual rows=1 loops=1)
+   Index Cond: ((thousand = 42) AND (tenthous = ANY ('{1,3,42}'::integer[])))
    Buffers: shared hit=5 read=2
-   ->  BitmapOr (actual rows=0 loops=1)
-         Buffers: shared hit=4 read=2
-         ->  Bitmap Index Scan on tenk1_thous_tenthous (actual rows=0 loops=1)
-               Index Cond: ((thousand = 42) AND (tenthous = 1))
-               Buffers: shared read=2
-         ->  Bitmap Index Scan on tenk1_thous_tenthous (actual rows=0 loops=1)
-               Index Cond: ((thousand = 42) AND (tenthous = 3))
-               Buffers: shared hit=2
-         ->  Bitmap Index Scan on tenk1_thous_tenthous (actual rows=1 loops=1)
-               Index Cond: ((thousand = 42) AND (tenthous = 42))
-               Buffers: shared hit=2
  Planning:
    Buffers: shared hit=51
-(17 rows)
+(5 rows)
 
 SELECT * FROM tenk1
   WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42);
@@ -1869,12 +1857,12 @@
 EXPLAIN (ANALYZE, COSTS OFF, BUFFERS, TIMING OFF, SUMMARY OFF)
 SELECT count(*) FROM tenk1
   WHERE hundred = 42 AND (thousand = 42 OR thousand = 99);
-                                         QUERY PLAN                                         
---------------------------------------------------------------------------------------------
+                                      QUERY PLAN                                      
+--------------------------------------------------------------------------------------
  Aggregate (actual rows=1 loops=1)
    Buffers: shared hit=5 read=3
    ->  Bitmap Heap Scan on tenk1 (actual rows=10 loops=1)
-         Recheck Cond: ((hundred = 42) AND ((thousand = 42) OR (thousand = 99)))
+         Recheck Cond: ((hundred = 42) AND (thousand = ANY ('{42,99}'::integer[])))
          Heap Blocks: exact=10
          Buffers: shared hit=5 read=3
          ->  BitmapAnd (actual rows=0 loops=1)
@@ -1882,15 +1870,10 @@
                ->  Bitmap Index Scan on tenk1_hundred (actual rows=100 loops=1)
                      Index Cond: (hundred = 42)
                      Buffers: shared read=2
-               ->  BitmapOr (actual rows=0 loops=1)
+               ->  Bitmap Index Scan on tenk1_thous_tenthous (actual rows=20 loops=1)
+                     Index Cond: (thousand = ANY ('{42,99}'::integer[]))
                      Buffers: shared hit=3 read=1
-                     ->  Bitmap Index Scan on tenk1_thous_tenthous (actual rows=10 loops=1)
-                           Index Cond: (thousand = 42)
-                           Buffers: shared hit=2
-                     ->  Bitmap Index Scan on tenk1_thous_tenthous (actual rows=10 loops=1)
-                           Index Cond: (thousand = 99)
-                           Buffers: shared hit=1 read=1
-(19 rows)
+(14 rows)
 
 SELECT count(*) FROM tenk1
   WHERE hundred = 42 AND (thousand = 42 OR thousand = 99);
diff -U3 /home/alena/postgrespro7/src/test/regress/expected/join.out /home/alena/postgrespro7/src/test/regress/results/join.out
--- /home/alena/postgrespro7/src/test/regress/expected/join.out	2023-06-27 10:21:22.096306419 +0300
+++ /home/alena/postgrespro7/src/test/regress/results/join.out	2023-06-27 10:32:26.049288441 +0300
@@ -4207,10 +4207,10 @@
 select * from tenk1 a join tenk1 b on
   (a.unique1 = 1 and b.unique1 = 2) or
   ((a.unique2 = 3 or a.unique2 = 7) and b.hundred = 4);
-                                                      QUERY PLAN                                                      
-----------------------------------------------------------------------------------------------------------------------
+                                                       QUERY PLAN                                                       
+------------------------------------------------------------------------------------------------------------------------
  Nested Loop (actual rows=201 loops=1)
-   Join Filter: (((a.unique1 = 1) AND (b.unique1 = 2)) OR (((a.unique2 = 3) OR (a.unique2 = 7)) AND (b.hundred = 4)))
+   Join Filter: (((a.unique1 = 1) AND (b.unique1 = 2)) OR ((a.unique2 = ANY ('{3,7}'::integer[])) AND (b.hundred = 4)))
    Rows Removed by Join Filter: 102
    Buffers: shared hit=98
    ->  Bitmap Heap Scan on tenk1 b (actual rows=101 loops=1)
@@ -4228,7 +4228,7 @@
    ->  Materialize (actual rows=3 loops=101)
          Buffers: shared hit=8
          ->  Bitmap Heap Scan on tenk1 a (actual rows=3 loops=1)
-               Recheck Cond: ((unique1 = 1) OR (unique2 = 3) OR (unique2 = 7))
+               Recheck Cond: ((unique1 = 1) OR (unique2 = ANY ('{3,7}'::integer[])))
                Heap Blocks: exact=2
                Buffers: shared hit=8
                ->  BitmapOr (actual rows=0 loops=1)
@@ -4236,13 +4236,10 @@
                      ->  Bitmap Index Scan on tenk1_unique1 (actual rows=1 loops=1)
                            Index Cond: (unique1 = 1)
                            Buffers: shared hit=2
-                     ->  Bitmap Index Scan on tenk1_unique2 (actual rows=1 loops=1)
-                           Index Cond: (unique2 = 3)
-                           Buffers: shared hit=2
-                     ->  Bitmap Index Scan on tenk1_unique2 (actual rows=1 loops=1)
-                           Index Cond: (unique2 = 7)
-                           Buffers: shared hit=2
-(33 rows)
+                     ->  Bitmap Index Scan on tenk1_unique2 (actual rows=2 loops=1)
+                           Index Cond: (unique2 = ANY ('{3,7}'::integer[]))
+                           Buffers: shared hit=4
+(30 rows)
 
 --
 -- test placement of movable quals in a parameterized join tree
diff -U3 /home/alena/postgrespro7/src/test/regress/expected/stats_ext.out /home/alena/postgrespro7/src/test/regress/results/stats_ext.out
--- /home/alena/postgrespro7/src/test/regress/expected/stats_ext.out	2023-06-27 00:35:33.761010034 +0300
+++ /home/alena/postgrespro7/src/test/regress/results/stats_ext.out	2023-06-27 10:32:37.537436241 +0300
@@ -1322,19 +1322,19 @@
 SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 51) AND b = ''1''');
  estimated | actual 
 -----------+--------
-        99 |    100
+       100 |    100
 (1 row)
 
 SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 51) AND (b = ''1'' OR b = ''2'')');
  estimated | actual 
 -----------+--------
-        99 |    100
+       100 |    100
 (1 row)
 
 SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE (a = 1 OR a = 2 OR a = 51 OR a = 52) AND (b = ''1'' OR b = ''2'')');
  estimated | actual 
 -----------+--------
-       197 |    200
+       200 |    200
 (1 row)
 
 -- OR clauses referencing different attributes are incompatible
@@ -1664,19 +1664,19 @@
 SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (a * 2) = 102) AND upper(b) = ''1''');
  estimated | actual 
 -----------+--------
-        99 |    100
+       100 |    100
 (1 row)
 
 SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (a * 2) = 102) AND (upper(b) = ''1'' OR upper(b) = ''2'')');
  estimated | actual 
 -----------+--------
-        99 |    100
+       100 |    100
 (1 row)
 
 SELECT * FROM check_estimated_rows('SELECT * FROM functional_dependencies WHERE ((a * 2) = 2 OR (a * 2) = 4 OR (a * 2) = 102 OR (a * 2) = 104) AND (upper(b) = ''1'' OR upper(b) = ''2'')');
  estimated | actual 
 -----------+--------
-       197 |    200
+       200 |    200
 (1 row)
 
 -- OR clauses referencing different attributes
diff -U3 /home/alena/postgrespro7/src/test/regress/expected/partition_prune.out /home/alena/postgrespro7/src/test/regress/results/partition_prune.out
--- /home/alena/postgrespro7/src/test/regress/expected/partition_prune.out	2023-06-27 10:31:39.596703531 +0300
+++ /home/alena/postgrespro7/src/test/regress/results/partition_prune.out	2023-06-27 10:32:48.285575599 +0300
@@ -82,23 +82,25 @@
 (2 rows)
 
 EXPLAIN (ANALYZE, COSTS OFF, BUFFERS, TIMING OFF, SUMMARY OFF) select * from lp where a = 'a' or a = 'c';
-                        QUERY PLAN                        
-----------------------------------------------------------
+                      QUERY PLAN                      
+------------------------------------------------------
  Append (actual rows=0 loops=1)
    ->  Seq Scan on lp_ad lp_1 (actual rows=0 loops=1)
-         Filter: ((a = 'a'::bpchar) OR (a = 'c'::bpchar))
+         Filter: (a = ANY ('{a,c}'::bpchar[]))
    ->  Seq Scan on lp_bc lp_2 (actual rows=0 loops=1)
-         Filter: ((a = 'a'::bpchar) OR (a = 'c'::bpchar))
-(5 rows)
+         Filter: (a = ANY ('{a,c}'::bpchar[]))
+ Planning:
+   Buffers: shared hit=16
+(7 rows)
 
 EXPLAIN (ANALYZE, COSTS OFF, BUFFERS, TIMING OFF, SUMMARY OFF) select * from lp where a is not null and (a = 'a' or a = 'c');
-                                   QUERY PLAN                                   
---------------------------------------------------------------------------------
+                             QUERY PLAN                              
+---------------------------------------------------------------------
  Append (actual rows=0 loops=1)
    ->  Seq Scan on lp_ad lp_1 (actual rows=0 loops=1)
-         Filter: ((a IS NOT NULL) AND ((a = 'a'::bpchar) OR (a = 'c'::bpchar)))
+         Filter: ((a IS NOT NULL) AND (a = ANY ('{a,c}'::bpchar[])))
    ->  Seq Scan on lp_bc lp_2 (actual rows=0 loops=1)
-         Filter: ((a IS NOT NULL) AND ((a = 'a'::bpchar) OR (a = 'c'::bpchar)))
+         Filter: ((a IS NOT NULL) AND (a = ANY ('{a,c}'::bpchar[])))
 (5 rows)
 
 explain (costs off) select * from lp where a <> 'g';
@@ -518,8 +520,10 @@
                   QUERY PLAN                  
 ----------------------------------------------
  Seq Scan on rlp2 rlp (actual rows=0 loops=1)
-   Filter: ((a = 1) OR (a = 7))
-(2 rows)
+   Filter: (a = ANY ('{1,7}'::integer[]))
+ Planning:
+   Buffers: shared hit=16
+(4 rows)
 
 explain (costs off) select * from rlp where a = 1 or b = 'ab';
                       QUERY PLAN                       
@@ -600,9 +604,9 @@
 --------------------------------------------------------------
  Append (actual rows=0 loops=1)
    ->  Seq Scan on rlp4_1 rlp_1 (actual rows=0 loops=1)
-         Filter: ((a = 20) OR (a = 40))
+         Filter: (a = ANY ('{20,40}'::integer[]))
    ->  Seq Scan on rlp5_default rlp_2 (actual rows=0 loops=1)
-         Filter: ((a = 20) OR (a = 40))
+         Filter: (a = ANY ('{20,40}'::integer[]))
 (5 rows)
 
 explain (costs off) select * from rlp3 where a = 20;   /* empty */
@@ -1933,10 +1937,10 @@
 
 EXPLAIN (ANALYZE, COSTS OFF, BUFFERS, TIMING OFF, SUMMARY OFF) select * from hp where a = 1 and b = 'abcde' and
   (c = 2 or c = 3);
-                              QUERY PLAN                              
-----------------------------------------------------------------------
+                                   QUERY PLAN                                   
+--------------------------------------------------------------------------------
  Seq Scan on hp2 hp (actual rows=0 loops=1)
-   Filter: ((a = 1) AND (b = 'abcde'::text) AND ((c = 2) OR (c = 3)))
+   Filter: ((c = ANY ('{2,3}'::integer[])) AND (a = 1) AND (b = 'abcde'::text))
    Rows Removed by Filter: 2
    Buffers: shared hit=1
 (4 rows)
@@ -2269,11 +2273,11 @@
          Workers Launched: N
          ->  Parallel Append (actual rows=N loops=N)
                ->  Parallel Seq Scan on ab_a1_b2 ab_1 (actual rows=N loops=N)
-                     Filter: ((b = 2) AND ((a = $0) OR (a = $1)))
+                     Filter: ((a = ANY (ARRAY[$0, $1])) AND (b = 2))
                ->  Parallel Seq Scan on ab_a2_b2 ab_2 (never executed)
-                     Filter: ((b = 2) AND ((a = $0) OR (a = $1)))
+                     Filter: ((a = ANY (ARRAY[$0, $1])) AND (b = 2))
                ->  Parallel Seq Scan on ab_a3_b2 ab_3 (actual rows=N loops=N)
-                     Filter: ((b = 2) AND ((a = $0) OR (a = $1)))
+                     Filter: ((a = ANY (ARRAY[$0, $1])) AND (b = 2))
 (16 rows)
 
 -- Test pruning during parallel nested loop query