citusdata / citusdata/citus

Local execution for insert..select with re-partitioning

Open
#3,726 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
12.8k
Forks
794
Avg merge
2d 14h
Merged PRs (30d)
31

Description

Currently INSERT..SELECT with re-partitioning throws an error if it is used in a local execution context:
```sql
postgres=# BEGIN;
BEGIN
postgres=# SELECT * FROM test WHERE x = 3;
NOTICE: executing the command locally: SELECT x, y FROM public.test_102056 test WHERE (x OPERATOR(pg_catalog.=) 3)
┌───┬───┐
│ x │ y │
├───┼───┤
└───┴───┘
(0 rows)

postgres=# INSERT INTO test (y, x) SELECT * FROM test;
ERROR: cannot execute command because a local execution has accessed a placement in the transaction
DETAIL: Some parallel commands cannot be executed if a previous command has already been executed locally
HINT: Try re-running the transaction with "SET LOCAL citus.enable_local_execution TO OFF;"
```

We'd likely need some logic to deal with `perPlacementQueries` in `ExtractLocalAndRemoteTasks`

Alternative could be to fall back to execution via the coordinator.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.