Inline CTEs for modification queries
Open
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
Assessment
This issue has not been assessed yet.