Re: Incorrect cost for MergeAppend

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Incorrect cost for MergeAppend
Дата
Msg-id CAApHDvpsDSR0ff6KkHuxmZWmM9V9kYHT_5AgRFwhoes=yeJiBA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Incorrect cost for MergeAppend  (Alexander Kuzmenkov <akuzmenkov@timescale.com>)
Ответы Re: Incorrect cost for MergeAppend  (Alexander Kuzmenkov <akuzmenkov@timescale.com>)
Список pgsql-hackers
On Wed, 31 Jan 2024 at 00:06, Alexander Kuzmenkov
<akuzmenkov@timescale.com> wrote:
> Here is a small patch that reproduces the problem on two tables with
> inheritance, and fixes it. I'll add it to the Commitfest.

Good catch.

It seems to have been broken since MergeAppends were added in 11cad29c9.

The code fix looks good to me.

The tests look a bit heavy.  I wondered if you could have used a UNION
ALL query with the tenk1 table so you didn't have to create tables,
however, I see that case works ok since the parent->tuples is set in
set_subquery_size_estimates() from "rel->tuples =
sub_final_rel->cheapest_total_path->rows;".

I played around with the following and see your patch changes the plan
to a Merge Append away from an Append -> Sort plan.

create table tenk_parent (like tenk1);
alter table tenk1 inherit tenk_parent;
alter table tenk2 inherit tenk_parent;
explain (costs off) select * from tenk_parent where thousand = 0 order
by tenthous;
alter table tenk1 no inherit tenk_parent;
alter table tenk2 no inherit tenk_parent;

I'm just not sure if we should be messing with tenk1 and tenk2 like that.

You should likely focus on trying to find a test that does not require
making 2 tables with 10k rows.

David



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Aleksander Alekseev
Дата:
Сообщение: Re: Incorrect cost for MergeAppend
Следующее
От: Alvaro Herrera
Дата:
Сообщение: scram_iterations is undocumented GUC_REPORT