From: | Aleksander Alekseev <aleksander(at)timescale(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Cc: | Alexander Kuzmenkov <akuzmenkov(at)timescale(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> |
Subject: | Re: Incorrect cost for MergeAppend |
Date: | 2024-01-30 12:18:44 |
Message-ID: | CAJ7c6TO=kGaDUj-vsF3Fm-Zog=x7HA2Ai+HS81FHKcyLLQOEFA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
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
From | Date | Subject | |
---|---|---|---|
Next Message | David Rowley | 2024-01-30 12:20:21 | Re: Incorrect cost for MergeAppend |
Previous Message | Masahiko Sawada | 2024-01-30 12:16:36 | Re: Question on LWLockMode in dsa.c |