Skip to content

Commit d83475b

Browse files
author
Maksim Milyutin
committed
Add test case for index scans for child nodes under enable_parent is set
1 parent 2d224b6 commit d83475b

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

expected/pathman_basic.out

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,71 @@ EXPLAIN (COSTS OFF) SELECT * FROM special_case_1_ind_o_s WHERE val < 75 AND comm
14781478
Index Cond: ((val < 75) AND (comment = 'a'::text))
14791479
(5 rows)
14801480

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+
14811546
DROP SCHEMA test CASCADE;
14821547
NOTICE: drop cascades to 13 other objects
14831548
DROP EXTENSION pg_pathman CASCADE;

sql/pathman_basic.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,19 @@ EXPLAIN (COSTS OFF) SELECT * FROM special_case_1_ind_o_s WHERE val < 75 AND comm
394394
SELECT set_enable_parent('special_case_1_ind_o_s', false);
395395
EXPLAIN (COSTS OFF) SELECT * FROM special_case_1_ind_o_s WHERE val < 75 AND comment = 'a';
396396

397+
/* Test index scans on child relation under enable_parent is set */
398+
CREATE TABLE test_index_on_childs(c1 integer not null, c2 integer);
399+
CREATE INDEX ON test_index_on_childs(c2);
400+
INSERT INTO test_index_on_childs SELECT i, (random()*10000)::integer FROM generate_series(1, 10000) i;
401+
SELECT create_range_partitions('test_index_on_childs', 'c1', 1, 1000, 0, false);
402+
SELECT add_range_partition('test_index_on_childs', 1, 1000, 'test_index_on_childs_1_1K');
403+
SELECT append_range_partition('test_index_on_childs', 'test_index_on_childs_1K_2K');
404+
SELECT append_range_partition('test_index_on_childs', 'test_index_on_childs_2K_3K');
405+
SELECT append_range_partition('test_index_on_childs', 'test_index_on_childs_3K_4K');
406+
SELECT append_range_partition('test_index_on_childs', 'test_index_on_childs_4K_5K');
407+
SELECT set_enable_parent('test_index_on_childs', true);
408+
VACUUM ANALYZE test_index_on_childs;
409+
EXPLAIN (COSTS OFF) SELECT * FROM test_index_on_childs WHERE c1 > 100 AND c1 < 2500 AND c2 = 500;
397410

398411
DROP SCHEMA test CASCADE;
399412
DROP EXTENSION pg_pathman CASCADE;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy