-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Per @martint comment #15104 (comment)
I'm thinking of syntax like this:
CREATE MATERIALIZED VIEW <name> (GRACE PERIOD <interval>)? (WHEN STALE (FAIL | REFRESH))? AS (<query>) (WITH NO DATA)?
- A materialized view can be in either
usableorunusablestate.GRACE PERIODindicates the maximum allowed time since creation or last refresh before the MV is considered unusable. If omitted, the MV will always be considered usable (i.e., infinite grace period)WHEN STALE (FAIL | REFRESH)indicates what to do once the MV is consideredunusable. IfFAIL, querying the MV will result in a failure indicating the MV is stale. IfREFRESH, the query will transparently produce the correct results as if the MV was up to date (either by refreshing the MV before the query runs or by running the underlying query directly as if it were a regular view.WITH NO DATAcauses the MV to be created but not populated in the beginning. One open question is whether the MV is considered unusable until the first refresh occurs (explicitly viaREFRESH MATERIALIZED VIEWor implicitly ifWHEN STALE REFRESHis specified), or whether it's considered within the grace period. In the latter case, theWHEN STALEclause would only make sense when a grace period is specified explicitly (since otherwise, it's infinite), so we could constrain it syntactically just for that scenario.We don't need to implement all those features up front, but I'd like to have a plausible plan for what the syntax would look like when we get to it.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request