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

CTE behavior: Citus vs pg #664

Open
begriffs opened this issue May 10, 2018 · 5 comments
Open

CTE behavior: Citus vs pg #664

begriffs opened this issue May 10, 2018 · 5 comments

Comments

@begriffs
Copy link
Contributor

Communication goals (e.g. detailed howto vs orientation)

Alert people in case they rely on pg semantics for their CTEs.

Good locations for content in docs structure

Add a CTE section to https://docs.citusdata.com/en/v7.3/develop/reference_sql.html

How does this work? (devs)

As pointed out in citusdata/citus#2153:

  • We execute CTEs one-by-one, in order of appearance
  • CTEs can see the result of other modifying CTEs
  • Each CTE may work on different snapshots (read committed semantics)

We can address the third point by using repeatable mode as mentioned in citusdata/citus#1804. A challenge is that repeatable read needs to be set at the start of a transaction block and the CTE might appear mid-transaction block.

@marcocitus
Copy link
Member

We can address the third point by using repeatable mode as mentioned in citusdata/citus#1804. A challenge is that repeatable read needs to be set at the start of a transaction block and the CTE might appear mid-transaction block.

Just a note that this isn't actually implemented yet. Setting repeatable read mode on the coordinator does not propagate to the workers.

@jonels-msft
Copy link
Member

@marcocitus how is our CTE support in 9.0? Any changes from what's listed above?

@marcocitus
Copy link
Member

No changes

@JelteF
Copy link
Contributor

JelteF commented Jan 23, 2020

In citus 9.2 CTEs can now be inlined, i.e. they act the same as a subquery. This happens automatically except when:

  1. you use WITH MATERIALIZED
  2. you use the CTE more than once
  3. either the CTE or the query it is used in is a modifying query
  4. you use a volatile function, like random()

@onderkalaci
Copy link
Member

fyi, I'll open a separate issue on CTE pushdown (CTE inlining) in Citus 9.2, and give more detail information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants