Skip to content

Proposal for qual checking and pushdown #90

@abramsh

Description

@abramsh

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 execute and 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.
  • New plan state variable quals_pushed_down that is only true if
    • Multicorn parsed ALL quals (it can't support OR(s), etc, today)
    • can_filter returned ALL quals
  • In both scans and parameterized paths, push down quals returned from can_filter and leave any remaining for Postgres
  • Only push down limit/offset if quals_pushed_down is true

We can then, over time, add support for parsing more qual types - like OR(s)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions