Precheck to consider path costs for partial paths

Nikita Malakhov <hukutoc@gmail.com>

From: Nikita Malakhov <hukutoc@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-12-03T18:24:37Z
Lists: pgsql-hackers

Attachments

Hi hackers!

I'd stumbled upon the discussion [1] on TPC-DS query performance,
looked into code that caused this behavior and saw that partial hash,
merge and nested loop paths are discarded regardless of costs
if they have more pathkeys.

I've excluded the pathkey chain length condition from the precheck function
and added passing precalculated startup cost in addition to total cost,
and it seems to produce a more effective plan for case in [1].

Please check the attached patch. I'm very interested if my assumption
is correct or not.

[1]
https://www.postgresql.org/message-id/flat/SEZPR06MB649422CDEBEBBA3915154EE58A232%40SEZPR06MB6494.apcprd06.prod.outlook.com

-- 
Regards,
Nikita Malakhov
Postgres Professional
The Russian Postgres Company
https://postgrespro.ru/