citusdata / citusdata/citus

Inline CTEs for modification queries

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

Description

As @tejeswarm noted, Postgres does inline CTEs when the top-level command is modification, whereas Citus skips.

```C
Postgres

SS_process_ctes
    CmdType         cmdType = ((Query *) cte->ctequery)->commandType;
    if (cmdType == CMD_SELECT && !contain_dml(cte->ctequery) &&....

 

Citus

InlineCTEsInQueryTree(Query *query)
    PostgreSQLCTEInlineCondition(cte, query->commandType))
        if  cmdType == CMD_SELECT && !contain_dml(cte->ctequery) &&...
```

We should be careful about stable functions inside CTEs.

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.