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

sql: permit creation and refreshing of materialized views as of system time #56167

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jordanlewis
Copy link
Member

Depends on #55916.

Add the ability to CREATE and REFRESH MATERIALIZED VIEWS, AS OF SYSTEM
TIME. The purpose of this is to allow the expensive backfill operations
to happen at a timestamp in the past to avoid contention.

Currently, this is a little bit broken, because schema changes of the
backing tables of the views can wreak havoc when performed at different
system times.

Release note (sql change): add AOST capabilities to materialized views.

Previously, running a statement of the form

    CREATE TABLE t AS SELECT ... FROM ... AS OF SYSTEM TIME x

was not supported.

Now, it is supported. The semantics are that the table creation happens
at the transaction timestamp, but the backfill that's performed to fetch
the data from the `SELECT` is performed at the user-specified timestamp
x.

This is useful for copying data from tables that are experiencing write
traffic. Reading the contended table's data at a historical timestamp
avoids contention on the CREATE TABLE AS.

Release note (sql change): CREATE TABLE AS SELECT ... FROM ... AS OF
SYSTEM TIME x is now supported.
Add the ability to CREATE and REFRESH MATERIALIZED VIEWS, AS OF SYSTEM
TIME. The purpose of this is to allow the expensive backfill operations
to happen at a timestamp in the past to avoid contention.

Currently, this is a little bit broken, because schema changes of the
backing tables of the views can wreak havoc when performed at different
system times.

Release note (sql change): add AOST capabilities to materialized views.
@jordanlewis jordanlewis requested a review from a team as a code owner October 30, 2020 23:31
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@awoods187
Copy link
Contributor

this is a cool idea!

@tbg tbg added the X-noremind Bots won't notify about PRs with X-noremind label May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
X-noremind Bots won't notify about PRs with X-noremind
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants