Skip to content

Commit e4bb77b

Browse files
committed
Pgpro-specific part of porting to 12.
1 parent 08113c9 commit e4bb77b

11 files changed

+183
-3
lines changed

expected/pathman_hashjoin.out

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* pathman_hashjoin_1.out and pathman_hashjoin_2.out seem to deal with pgpro's
3+
* different behaviour. 8edd0e794 (>= 12) Append nodes with single subplan
4+
* are eliminated, hence pathman_hashjoin_3.out
5+
*/
16
\set VERBOSITY terse
27
SET search_path = 'public';
38
CREATE SCHEMA pathman;

expected/pathman_hashjoin_1.out

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* pathman_hashjoin_1.out and pathman_hashjoin_2.out seem to deal with pgpro's
3+
* different behaviour. 8edd0e794 (>= 12) Append nodes with single subplan
4+
* are eliminated, hence pathman_hashjoin_3.out
5+
*/
16
\set VERBOSITY terse
27
SET search_path = 'public';
38
CREATE SCHEMA pathman;

expected/pathman_hashjoin_2.out

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* pathman_hashjoin_1.out and pathman_hashjoin_2.out seem to deal with pgpro's
3+
* different behaviour. 8edd0e794 (>= 12) Append nodes with single subplan
4+
* are eliminated, hence pathman_hashjoin_3.out
5+
*/
16
\set VERBOSITY terse
27
SET search_path = 'public';
38
CREATE SCHEMA pathman;

expected/pathman_hashjoin_3.out

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* pathman_hashjoin_1.out and pathman_hashjoin_2.out seem to deal with pgpro's
3+
* different behaviour. 8edd0e794 (>= 12) Append nodes with single subplan
4+
* are eliminated, hence pathman_hashjoin_3.out
5+
*/
6+
\set VERBOSITY terse
7+
SET search_path = 'public';
8+
CREATE SCHEMA pathman;
9+
CREATE EXTENSION pg_pathman SCHEMA pathman;
10+
CREATE SCHEMA test;
11+
CREATE TABLE test.range_rel (
12+
id SERIAL PRIMARY KEY,
13+
dt TIMESTAMP NOT NULL,
14+
txt TEXT);
15+
CREATE INDEX ON test.range_rel (dt);
16+
INSERT INTO test.range_rel (dt, txt)
17+
SELECT g, md5(g::TEXT) FROM generate_series('2015-01-01', '2015-04-30', '1 day'::interval) as g;
18+
SELECT pathman.create_range_partitions('test.range_rel', 'DT', '2015-01-01'::DATE, '1 month'::INTERVAL);
19+
create_range_partitions
20+
-------------------------
21+
4
22+
(1 row)
23+
24+
CREATE TABLE test.num_range_rel (
25+
id SERIAL PRIMARY KEY,
26+
txt TEXT);
27+
SELECT pathman.create_range_partitions('test.num_range_rel', 'id', 0, 1000, 4);
28+
create_range_partitions
29+
-------------------------
30+
4
31+
(1 row)
32+
33+
INSERT INTO test.num_range_rel
34+
SELECT g, md5(g::TEXT) FROM generate_series(1, 3000) as g;
35+
SET pg_pathman.enable_runtimeappend = OFF;
36+
SET pg_pathman.enable_runtimemergeappend = OFF;
37+
VACUUM;
38+
/*
39+
* Hash join
40+
*/
41+
SET enable_indexscan = ON;
42+
SET enable_seqscan = OFF;
43+
SET enable_nestloop = OFF;
44+
SET enable_hashjoin = ON;
45+
SET enable_mergejoin = OFF;
46+
EXPLAIN (COSTS OFF)
47+
SELECT * FROM test.range_rel j1
48+
JOIN test.range_rel j2 on j2.id = j1.id
49+
JOIN test.num_range_rel j3 on j3.id = j1.id
50+
WHERE j1.dt < '2015-03-01' AND j2.dt >= '2015-02-01' ORDER BY j2.dt;
51+
QUERY PLAN
52+
---------------------------------------------------------------------------------
53+
Sort
54+
Sort Key: j2.dt
55+
-> Hash Join
56+
Hash Cond: (j3.id = j2.id)
57+
-> Append
58+
-> Index Scan using num_range_rel_1_pkey on num_range_rel_1 j3
59+
-> Index Scan using num_range_rel_2_pkey on num_range_rel_2 j3_1
60+
-> Index Scan using num_range_rel_3_pkey on num_range_rel_3 j3_2
61+
-> Index Scan using num_range_rel_4_pkey on num_range_rel_4 j3_3
62+
-> Hash
63+
-> Index Scan using range_rel_2_dt_idx on range_rel_2 j2
64+
Filter: (id IS NOT NULL)
65+
(12 rows)
66+
67+
DROP SCHEMA test CASCADE;
68+
NOTICE: drop cascades to 12 other objects
69+
DROP EXTENSION pg_pathman CASCADE;
70+
DROP SCHEMA pathman CASCADE;

expected/pathman_mergejoin.out

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* pathman_mergejoin_1.out and pathman_mergejoin_2.out seem to deal with pgpro's
3+
* different behaviour. 8edd0e794 (>= 12) Append nodes with single subplan
4+
* are eliminated, hence pathman_mergejoin_3.out
5+
*/
16
\set VERBOSITY terse
27
SET search_path = 'public';
38
CREATE SCHEMA pathman;

expected/pathman_mergejoin_1.out

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* pathman_mergejoin_1.out and pathman_mergejoin_2.out seem to deal with pgpro's
3+
* different behaviour. 8edd0e794 (>= 12) Append nodes with single subplan
4+
* are eliminated, hence pathman_mergejoin_3.out
5+
*/
16
\set VERBOSITY terse
27
SET search_path = 'public';
38
CREATE SCHEMA pathman;

expected/pathman_mergejoin_2.out

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* pathman_mergejoin_1.out and pathman_mergejoin_2.out seem to deal with pgpro's
3+
* different behaviour. 8edd0e794 (>= 12) Append nodes with single subplan
4+
* are eliminated, hence pathman_mergejoin_3.out
5+
*/
16
\set VERBOSITY terse
27
SET search_path = 'public';
38
CREATE SCHEMA pathman;

expected/pathman_mergejoin_3.out

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* pathman_mergejoin_1.out and pathman_mergejoin_2.out seem to deal with pgpro's
3+
* different behaviour. 8edd0e794 (>= 12) Append nodes with single subplan
4+
* are eliminated, hence pathman_mergejoin_3.out
5+
*/
6+
\set VERBOSITY terse
7+
SET search_path = 'public';
8+
CREATE SCHEMA pathman;
9+
CREATE EXTENSION pg_pathman SCHEMA pathman;
10+
CREATE SCHEMA test;
11+
CREATE TABLE test.range_rel (
12+
id SERIAL PRIMARY KEY,
13+
dt TIMESTAMP NOT NULL,
14+
txt TEXT);
15+
CREATE INDEX ON test.range_rel (dt);
16+
INSERT INTO test.range_rel (dt, txt)
17+
SELECT g, md5(g::TEXT) FROM generate_series('2015-01-01', '2015-04-30', '1 day'::interval) as g;
18+
SELECT pathman.create_range_partitions('test.range_rel', 'DT', '2015-01-01'::DATE, '1 month'::INTERVAL);
19+
create_range_partitions
20+
-------------------------
21+
4
22+
(1 row)
23+
24+
CREATE TABLE test.num_range_rel (
25+
id SERIAL PRIMARY KEY,
26+
txt TEXT);
27+
INSERT INTO test.num_range_rel SELECT g, md5(g::TEXT) FROM generate_series(1, 3000) as g;
28+
SELECT pathman.create_range_partitions('test.num_range_rel', 'id', 0, 1000, 4);
29+
create_range_partitions
30+
-------------------------
31+
4
32+
(1 row)
33+
34+
/*
35+
* Merge join between 3 partitioned tables
36+
*
37+
* test case for the fix of sorting, merge append and index scan issues
38+
* details in commit 54dd0486fc55b2d25cf7d095f83dee6ff4adee06
39+
*/
40+
SET enable_hashjoin = OFF;
41+
SET enable_nestloop = OFF;
42+
SET enable_mergejoin = ON;
43+
EXPLAIN (COSTS OFF)
44+
SELECT * FROM test.range_rel j1
45+
JOIN test.range_rel j2 on j2.id = j1.id
46+
JOIN test.num_range_rel j3 on j3.id = j1.id
47+
WHERE j1.dt < '2015-03-01' AND j2.dt >= '2015-02-01' ORDER BY j2.dt;
48+
QUERY PLAN
49+
---------------------------------------------------------------------------------
50+
Sort
51+
Sort Key: j2.dt
52+
-> Merge Join
53+
Merge Cond: (j2.id = j3.id)
54+
-> Index Scan using range_rel_2_pkey on range_rel_2 j2
55+
Index Cond: (id IS NOT NULL)
56+
-> Append
57+
-> Index Scan using num_range_rel_1_pkey on num_range_rel_1 j3
58+
-> Index Scan using num_range_rel_2_pkey on num_range_rel_2 j3_1
59+
-> Index Scan using num_range_rel_3_pkey on num_range_rel_3 j3_2
60+
-> Index Scan using num_range_rel_4_pkey on num_range_rel_4 j3_3
61+
(11 rows)
62+
63+
SET enable_hashjoin = ON;
64+
SET enable_nestloop = ON;
65+
DROP SCHEMA test CASCADE;
66+
NOTICE: drop cascades to 12 other objects
67+
DROP EXTENSION pg_pathman;
68+
DROP SCHEMA pathman CASCADE;

sql/pathman_hashjoin.sql

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*
2+
* pathman_hashjoin_1.out and pathman_hashjoin_2.out seem to deal with pgpro's
3+
* different behaviour. 8edd0e794 (>= 12) Append nodes with single subplan
4+
* are eliminated, hence pathman_hashjoin_3.out
5+
*/
6+
17
\set VERBOSITY terse
28

39
SET search_path = 'public';

sql/pathman_mergejoin.sql

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*
2+
* pathman_mergejoin_1.out and pathman_mergejoin_2.out seem to deal with pgpro's
3+
* different behaviour. 8edd0e794 (>= 12) Append nodes with single subplan
4+
* are eliminated, hence pathman_mergejoin_3.out
5+
*/
6+
17
\set VERBOSITY terse
28

39
SET search_path = 'public';

src/include/compat/pg_compat.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@
246246
create_append_path(NULL, (rel), (subpaths), NIL, NIL, (required_outer), \
247247
(parallel_workers), false, NIL, -1)
248248
#else
249-
/* TODO pgpro version */
249+
/* TODO pgpro version? Looks like something is not ported yet */
250250
#define create_append_path_compat(rel, subpaths, required_outer, parallel_workers) \
251-
create_append_path(NULL, (rel), (subpaths), NIL, (required_outer), \
252-
(parallel_workers), false, NIL, -1, false, NIL)
251+
create_append_path(NULL, (rel), (subpaths), NIL, NIL, (required_outer), \
252+
(parallel_workers), false, NIL, -1, false)
253253
#endif /* PGPRO_VERSION */
254254

255255
#elif PG_VERSION_NUM >= 110000

0 commit comments

Comments
 (0)