Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherrypick "Orca enable update and delete on partitioned tables (#14129)" #822

Merged
merged 2 commits into from
Jan 2, 2025

Conversation

jiaqizho
Copy link
Contributor

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


@my-ship-it my-ship-it added the cherry-pick cherry-pick upstream commts label Dec 30, 2024
@jiaqizho jiaqizho force-pushed the cherry-pick-orca-in-path-order-3 branch from 23d9c0f to 2681d34 Compare December 31, 2024 03:03
Commit 89522085ad9 adds back dynamic scan nodes which requires a different
execution model for modifying partitioned tables. After this change we cannot
assume that the modify table relation directly references a leaf partition.
Instead, dynamic scan node references a root partition and requires tuple
routing in order to find the leaf partition.

This commit provides the framework to force tuple routing and updates the ORCA
side to allow generation of DML plans on partitioned tables. There is no longer
a need for ORCA to generate a partition selector node and OIDs. Instead, that
work is now handled in the tuple routing framework.

After this commit, ORCA is able to handle UPDATE/DELETE on partition tables:
  ```sql
  CREATE TABLE pt (a int, b int) PARTITION BY RANGE(b) (START (0) END (7) EVERY (3));
  INSERT INTO pt SELECT i, i%6 FROM generate_series(1, 100)i;

  UPDATE pt SET b=5 WHERE b=2;
  DELETE FROM pt WHERE b=1;
  ```

Example DELETE plan:
  ```
                  QUERY PLAN
  ------------------------------------------
   Delete on pt
     ->  Dynamic Seq Scan on pt pt_1
           Number of partitions to scan: 1
           Filter: (b = 1)
   Optimizer: Pivotal Optimizer (GPORCA)
  ```

And the plan node looks something like:
  ```
  {PLANNEDSTMT
  :commandType 4
  :planGen 1
  ...
  :planTree
     {MODIFYTABLE
     ...
     :plans (
        {DYNAMICSEQSCAN
        :scanrelid 2
        :partOids (o 286823)
        ...
        }
     )
     ...
     }
  }
  ```
@jiaqizho jiaqizho force-pushed the cherry-pick-orca-in-path-order-3 branch 2 times, most recently from 0729f30 to f6b4497 Compare December 31, 2024 08:08
After CBDB merged with PG14, we need to provide additional
support for the case where the update/delete is a dynamic (any)
scan operator. This is because in `ExecModifyTable`, PG14 has
an assumption: the current `resultRelInfo` will not be a root
partition table.

The current commit disables the update/delete generated by ORCA
on the partition table, and this behavior will be supported in
subsequent changes.
@jiaqizho jiaqizho force-pushed the cherry-pick-orca-in-path-order-3 branch from f6b4497 to 25f806d Compare December 31, 2024 09:17
@my-ship-it my-ship-it self-requested a review January 2, 2025 03:42
@my-ship-it my-ship-it merged commit a0f3982 into apache:main Jan 2, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick cherry-pick upstream commts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants