mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
Add a materialized view relations.
A materialized view has a rule just like a view and a heap and other physical properties like a table. The rule is only used to populate the table, references in queries refer to the materialized data. This is a minimal implementation, but should still be useful in many cases. Currently data is only populated "on demand" by the CREATE MATERIALIZED VIEW and REFRESH MATERIALIZED VIEW statements. It is expected that future releases will add incremental updates with various timings, and that a more refined concept of defining what is "fresh" data will be developed. At some point it may even be possible to have queries use a materialized in place of references to underlying tables, but that requires the other above-mentioned features to be working first. Much of the documentation work by Robert Haas. Review by Noah Misch, Thom Brown, Robert Haas, Marko Tiikkaja Security review by KaiGai Kohei, with a decision on how best to implement sepgsql still pending.
This commit is contained in:
@@ -713,6 +713,7 @@ typedef struct RangeTblEntry
|
||||
*/
|
||||
Oid relid; /* OID of the relation */
|
||||
char relkind; /* relation kind (see pg_class.relkind) */
|
||||
bool isResultRel; /* used in target of SELECT INTO or similar */
|
||||
|
||||
/*
|
||||
* Fields valid for a subquery RTE (else NULL):
|
||||
@@ -1135,6 +1136,7 @@ typedef enum ObjectType
|
||||
OBJECT_INDEX,
|
||||
OBJECT_LANGUAGE,
|
||||
OBJECT_LARGEOBJECT,
|
||||
OBJECT_MATVIEW,
|
||||
OBJECT_OPCLASS,
|
||||
OBJECT_OPERATOR,
|
||||
OBJECT_OPFAMILY,
|
||||
@@ -2447,6 +2449,8 @@ typedef struct ExplainStmt
|
||||
* A query written as CREATE TABLE AS will produce this node type natively.
|
||||
* A query written as SELECT ... INTO will be transformed to this form during
|
||||
* parse analysis.
|
||||
* A query written as CREATE MATERIALIZED view will produce this node type,
|
||||
* during parse analysis, since it needs all the same data.
|
||||
*
|
||||
* The "query" field is handled similarly to EXPLAIN, though note that it
|
||||
* can be a SELECT or an EXECUTE, but not other DML statements.
|
||||
@@ -2457,9 +2461,21 @@ typedef struct CreateTableAsStmt
|
||||
NodeTag type;
|
||||
Node *query; /* the query (see comments above) */
|
||||
IntoClause *into; /* destination table */
|
||||
ObjectType relkind; /* type of object */
|
||||
bool is_select_into; /* it was written as SELECT INTO */
|
||||
} CreateTableAsStmt;
|
||||
|
||||
/* ----------------------
|
||||
* REFRESH MATERIALIZED VIEW Statement
|
||||
* ----------------------
|
||||
*/
|
||||
typedef struct RefreshMatViewStmt
|
||||
{
|
||||
NodeTag type;
|
||||
bool skipData; /* true for WITH NO DATA */
|
||||
RangeVar *relation; /* relation to insert into */
|
||||
} RefreshMatViewStmt;
|
||||
|
||||
/* ----------------------
|
||||
* Checkpoint Statement
|
||||
* ----------------------
|
||||
@@ -2517,7 +2533,7 @@ typedef struct ConstraintsSetStmt
|
||||
typedef struct ReindexStmt
|
||||
{
|
||||
NodeTag type;
|
||||
ObjectType kind; /* OBJECT_INDEX, OBJECT_TABLE, OBJECT_DATABASE */
|
||||
ObjectType kind; /* OBJECT_INDEX, OBJECT_TABLE, etc. */
|
||||
RangeVar *relation; /* Table or index to reindex */
|
||||
const char *name; /* name of database to reindex */
|
||||
bool do_system; /* include system tables in database case */
|
||||
|
||||
Reference in New Issue
Block a user