Re: NOT IN subquery optimization

From: "Li, Zheng" <zhelli(at)amazon(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: NOT IN subquery optimization
Date: 2019-11-13 22:25:56
Message-ID: E0D3286D-B229-40BD-8AEE-1F7FA820028C@amazon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Hackers,

I'm sending an updated patch:
1. add GUC enable_not_in_transform to guard the optimization/transformation, the guc is on by default.
2. fix a bug: bail out NOT IN transformation early in convert_ANY_sublink_to_join so that parse->rtable doesn't get appended conditions are not met for the transformation.
3. add a CTE not in test case.

Here are the conditions for the transformation:
/*
*Allow transformation from NOT IN query to ANTI JOIN if ALL of the
* following conditions are true:
* 1. The GUC apg_not_in_transform_enabled is set to true.
* 2. the NOT IN subquery is not hashable, in which case an expensive
* subplan will be generated if we don't transform.
* 3. the subquery does not define any CTE.
*/

Regards,
-----------
Zheng Li
AWS, Amazon Aurora PostgreSQL



Attachment Content-Type Size
not_in_to_anti_join_transformation_v2_3.patch application/octet-stream 171.5 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Dilger 2019-11-13 23:00:03 Re: Missing dependency tracking for TableFunc nodes
Previous Message Tom Lane 2019-11-13 22:17:06 Re: Role membership and DROP