Re: Incorrect cost for MergeAppend
Aleksander Alekseev <aleksander@timescale.com>
From: Aleksander Alekseev <aleksander@timescale.com>
To: pgsql-hackers@postgresql.org
Cc: Alexander Kuzmenkov <akuzmenkov@timescale.com>,
Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Date: 2024-01-30T12:18:44Z
Lists: pgsql-hackers
Hi,
> Here is a small patch that reproduces the problem on two tables with
> inheritance, and fixes it. I'll add it to the Commitfest.
Thanks for the patch.
I can confirm that it changes the plan from Sort + Append to MergeAppend.
Before:
```
explain (costs off) select * from ma0 where a < 1000 order by a;
QUERY PLAN
---------------------------------------------------------
Sort
Sort Key: ma0.a
-> Append
-> Index Only Scan using ma0_pkey on ma0 ma0_1
Index Cond: (a < 1000)
-> Seq Scan on ma1 ma0_2
Filter: (a < 1000)
```
After:
```
=# explain (costs off) select * from ma0 where a < 1000 order by a;
QUERY PLAN
---------------------------------------------------
Merge Append
Sort Key: ma0.a
-> Index Only Scan using ma0_pkey on ma0 ma0_1
Index Cond: (a < 1000)
-> Sort
Sort Key: ma0_2.a
-> Seq Scan on ma1 ma0_2
Filter: (a < 1000)
```
The rest of the tests pass.
--
Best regards,
Aleksander Alekseev
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix costing bug in MergeAppend
- 9d1a5354f58c 17.0 landed
-
Fix locking when fixing an incomplete split of a GIN internal page
- 6a1ea02c491d 17.0 cited