Re: Disabling options lowers the estimated cost of a query

From: Arne Roland <A(dot)Roland(at)index(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Disabling options lowers the estimated cost of a query
Date: 2021-04-15 18:13:18
Message-ID: 1451e2bccd3c46d283d74b99a26eb950@index.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

The startup cost is pretty expensive. This seems to be common issue using partition wise joins.

I attached a simplified reproducer. Thanks for having a look!

Regards

Arne

________________________________
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Sent: Friday, February 26, 2021 4:00:18 AM
To: Arne Roland
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Disabling options lowers the estimated cost of a query

Arne Roland <A(dot)Roland(at)index(dot)de> writes:
> I want to examine the exhaustive search and not the geqo here. I'd expect the exhaustive search to give the plan with the lowest cost, but apparently it doesn't. I have found a few dozen different querys where that isn't the case. I attached one straight forward example. For the join of two partitions a row first approach would have been reasonable.

Hmm. While the search should be exhaustive, there are pretty aggressive
pruning heuristics (mostly in and around add_path()) that can cause us to
drop paths that don't seem to be enough better than other alternatives.
I suspect that the seqscan plan may have beaten out the other one at
some earlier stage that didn't think that the startup-cost advantage
was sufficient reason to keep it.

It's also possible that you've found a bug. I notice that both
plans are using incremental sort, which has been, um, rather buggy.
Hard to tell without a concrete test case to poke at.

regards, tom lane

Attachment Content-Type Size
optimizer_first_rows.sql application/sql 15.6 KB

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Tomas Vondra 2021-04-16 04:52:04 Re: Disabling options lowers the estimated cost of a query
Previous Message Tom Lane 2021-04-15 15:00:18 Re: Strange behavior once statistics are there