-
Notifications
You must be signed in to change notification settings - Fork 22
Description
As a follow up to #81, here is my proposal to push down quals properly while maintaining backwards compatibility with existing FDWs:
Background:
Today Multicorn2 qual pushdown is "best effort". It sends any quals it knows how to parse down to the FDW which may or may not push them down to it's underlying source system. Because they may not be pushed down, they are left in the plan for Postgres to filter again. Presumably this design was chosen because it is simple and Postgress spends very little effort for to re-check the filters.
However, the new limit/offset support is limited (no pun intended) because we can't safely push down limit/offset unless ALL the quals for a statement were pushed down.
Proposal:
- New Python method
can_filter( self, quals )that receives all quals that Multicorn knows how to parse- Return of “None” means "best effort". Send to
executeand Postgres will filter itself regardless (existing/default behavior) - Return of (subset of) quals list means push down those quals. Send only the returned quals to
execute, Postgres will only filter others.
- Return of “None” means "best effort". Send to
- New plan state variable
quals_pushed_downthat is only true if- Multicorn parsed ALL quals (it can't support OR(s), etc, today)
can_filterreturned ALL quals
- In both scans and parameterized paths, push down quals returned from
can_filterand leave any remaining for Postgres - Only push down limit/offset if
quals_pushed_downis true
We can then, over time, add support for parsing more qual types - like OR(s)