citusdata / citusdata/citus

Queries with subplans unnecessarily use local execution

Open
#6,277 2 comments 0 reactions 1 assignee Claimed by @onderkalaci View on GitHub
performance
Dominant language
C
Stars
12.8k
Forks
794
Avg merge
2d 14h
Merged PRs (30d)
31

Description

We currently use local execution for any query with a distributed subplan, which can significantly slow down queries that have shards on the coordinator (e.g. single node clusters).

The reason is that `IsMultiStatementTransaction()` returns true when executing the subplan, which triggers local execution. The reason that `IsMultiStatementTransaction()` returns true is that `MaybeExecutingUDF()` tries to infer whether we might be in a UDF by looking at the ExecutorLevel.

We raise the ExecutorLevel in `CitusExecutorRun` before calling `citusScanState->PreExecScan(citusScanState);`, so any subplan will see itself as being a nested execution, and therefore possibly in a UDF, and therefore should use local execution to make sure things like joins between local tables and reference tables work correctly.

It seems like we should only raise the executor level after `citusScanState->PreExecScan(citusScanState);`.

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.