pg_pathman
pg_pathman copied to clipboard
"RuntimeMergeAppend child's targetlist doesn't match RuntimeMergeAppend" error occurs on some sql
Problem description
When execute some sql,the following error occurs
ERROR: RuntimeMergeAppend child's targetlist doesn't match RuntimeMergeAppend
The following sql can reproduct this problem
CREATE EXTENSION pg_pathman;
CREATE TABLE partitioned_table(id INT NOT NULL, payload int);
create index on partitioned_table(payload);
INSERT INTO partitioned_table
SELECT generate_series(1, 1000), random();
SELECT create_hash_partitions('partitioned_table', 'id', 10);
CREATE TABLE some_table AS SELECT generate_series(1, 100) AS VAL;
set enable_seqscan =f;
explain analyze
SELECT max(id),payload FROM partitioned_table
WHERE id = (SELECT * FROM some_table LIMIT 1)
group by payload;
And, when change max(id),payload
to payload,max(id)
in select list, this sql executing is ok.
explain analyze
SELECT payload,max(id) FROM partitioned_table
WHERE id = (SELECT * FROM some_table LIMIT 1)
group by payload;
and the plan is as following:
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
GroupAggregate (cost=10000000000.17..10000000087.88 rows=11 width=8) (actual time=0.134..0.134 rows=1 loops=1)
Group Key: partitioned_table.payload
InitPlan 1 (returns $0)
-> Limit (cost=10000000000.00..10000000000.01 rows=1 width=4) (actual time=0.020..0.021 rows=1 loops=1)
-> Seq Scan on some_table (cost=10000000000.00..10000000035.50 rows=2550 width=4) (actual time=0.019..0.019 rows=1 loops=1)
-> Custom Scan (RuntimeMergeAppend) (cost=0.16..87.71 rows=11 width=8) (actual time=0.116..0.127 rows=1 loops=1)
Prune by: (partitioned_table.id = $0)
Sort Key: partitioned_table.payload
-> Index Scan using partitioned_table_0_payload_idx on partitioned_table_0 (cost=0.15..87.70 rows=11 width=8) (actual time=0.069..0.079 rows=1 loops=1)
Filter: (id = $0)
Rows Removed by Filter: 97
Planning time: 0.581 ms
Execution time: 0.212 ms
(13 rows)
Environment
postgres=# SELECT * FROM pg_extension;
extname | extowner | extnamespace | extrelocatable | extversion | extconfig | extcondition
------------+----------+--------------+----------------+------------+---------------+--------------
plpgsql | 10 | 11 | f | 1.0 | |
pg_pathman | 10 | 2200 | f | 1.5 | {16702,16713} | {"",""}
(2 rows)
postgres=# SELECT version();
version
----------------------------------------------------------------------------------------------------------
PostgreSQL 10.10 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit
(1 row)
And, I had tried in PG 10.10 and PG 11.3, only PG 10.10 occurs.
- PG 10.10 + pathman 1.5.8 NG
- PG 11.3 + pathman 1.5.8 OK