@@ -1478,6 +1478,71 @@ EXPLAIN (COSTS OFF) SELECT * FROM special_case_1_ind_o_s WHERE val < 75 AND comm
1478
1478
Index Cond: ((val < 75) AND (comment = 'a'::text))
1479
1479
(5 rows)
1480
1480
1481
+ /* Test index scans on child relation under enable_parent is set */
1482
+ CREATE TABLE test_index_on_childs(c1 integer not null, c2 integer);
1483
+ CREATE INDEX ON test_index_on_childs(c2);
1484
+ INSERT INTO test_index_on_childs SELECT i, (random()*10000)::integer FROM generate_series(1, 10000) i;
1485
+ SELECT create_range_partitions('test_index_on_childs', 'c1', 1, 1000, 0, false);
1486
+ NOTICE: sequence "test_index_on_childs_seq" does not exist, skipping
1487
+ create_range_partitions
1488
+ -------------------------
1489
+ 0
1490
+ (1 row)
1491
+
1492
+ SELECT add_range_partition('test_index_on_childs', 1, 1000, 'test_index_on_childs_1_1K');
1493
+ add_range_partition
1494
+ ---------------------------
1495
+ test_index_on_childs_1_1K
1496
+ (1 row)
1497
+
1498
+ SELECT append_range_partition('test_index_on_childs', 'test_index_on_childs_1K_2K');
1499
+ append_range_partition
1500
+ ----------------------------
1501
+ test_index_on_childs_1K_2K
1502
+ (1 row)
1503
+
1504
+ SELECT append_range_partition('test_index_on_childs', 'test_index_on_childs_2K_3K');
1505
+ append_range_partition
1506
+ ----------------------------
1507
+ test_index_on_childs_2K_3K
1508
+ (1 row)
1509
+
1510
+ SELECT append_range_partition('test_index_on_childs', 'test_index_on_childs_3K_4K');
1511
+ append_range_partition
1512
+ ----------------------------
1513
+ test_index_on_childs_3K_4K
1514
+ (1 row)
1515
+
1516
+ SELECT append_range_partition('test_index_on_childs', 'test_index_on_childs_4K_5K');
1517
+ append_range_partition
1518
+ ----------------------------
1519
+ test_index_on_childs_4K_5K
1520
+ (1 row)
1521
+
1522
+ SELECT set_enable_parent('test_index_on_childs', true);
1523
+ set_enable_parent
1524
+ -------------------
1525
+
1526
+ (1 row)
1527
+
1528
+ VACUUM ANALYZE test_index_on_childs;
1529
+ EXPLAIN (COSTS OFF) SELECT * FROM test_index_on_childs WHERE c1 > 100 AND c1 < 2500 AND c2 = 500;
1530
+ QUERY PLAN
1531
+ ----------------------------------------------------------------------------------------
1532
+ Append
1533
+ -> Index Scan using test_index_on_childs_c2_idx on test_index_on_childs
1534
+ Index Cond: (c2 = 500)
1535
+ Filter: ((c1 > 100) AND (c1 < 2500))
1536
+ -> Index Scan using test_index_on_childs_1_1k_c2_idx on test_index_on_childs_1_1k
1537
+ Index Cond: (c2 = 500)
1538
+ Filter: (c1 > 100)
1539
+ -> Index Scan using test_index_on_childs_1k_2k_c2_idx on test_index_on_childs_1k_2k
1540
+ Index Cond: (c2 = 500)
1541
+ -> Index Scan using test_index_on_childs_2k_3k_c2_idx on test_index_on_childs_2k_3k
1542
+ Index Cond: (c2 = 500)
1543
+ Filter: (c1 < 2500)
1544
+ (12 rows)
1545
+
1481
1546
DROP SCHEMA test CASCADE;
1482
1547
NOTICE: drop cascades to 13 other objects
1483
1548
DROP EXTENSION pg_pathman CASCADE;
0 commit comments