Incremental refresh of materialized views

The Computing Service Manager generates and merges materialized views in the database system, solving the problems of high maintenance cost and low efficiency of materialized views in large data warehouses, and achieving efficient materialized view updates and query performance improvements.

CN113228000BActive Publication Date: 2024-09-06SNOWFLAKE INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201980086492.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2018-10-26
Filing Date
2019-10-24
Publication Date
2024-09-06
Estimated Expiration
2039-10-24

AI Technical Summary

Technical Problem

In database systems, materialized views are costly and inefficient to maintain, especially in large data warehouses. There are challenges in maintaining the freshness and consistency of materialized views, which affects query performance and response time.

Method used

By introducing the Compute Service Manager in the database system, materialized views are generated and merged with source tables to detect updates that are not reflected in the materialized views and apply updates asynchronously when updates are detected, including inserting, deleting, or updating rows, preferably Refresh the materialized view and compress it if necessary to ensure the consistency of the materialized view with the source table.

Benefits of technology

It effectively reduces the cost and time of materialized view maintenance, improves query performance, ensures the freshness and accuracy of materialized views, and avoids restrictions on the external database task processing capabilities of client queries.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113228000B_ABST
    Figure CN113228000B_ABST
Patent Text Reader

Abstract

Disclosed are systems, methods, and apparatus for incrementally refreshing a materialized view. The method includes generating a materialized view based on a source table. The method includes merging the source table and the materialized view to generate a merged table, thereby identifying whether an update has been performed on the source table that is not reflected in the materialized view. The method includes, in response to detecting an update made to the source table that is not reflected in the materialized view, applying the update to the materialized view.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application claims priority to U.S. Provisional Patent Application No. 62 / 751,123, filed on October 26, 2018, entitled “INCREMENTAL REFRESH OF AMATERIALIZED VIEW,” the entire contents of which are incorporated herein by reference, including but not limited to those portions specifically appearing below, except for the portions incorporated by reference as follows: If any portion of the above application is inconsistent with this application, this application replaces the above application. Technical Field

[0003] Embodiments of the present disclosure relate to databases, and more particularly, to materialized views in database systems.

[0004] background

[0005] Databases are widely used for data storage and access in computing applications. The goal of database storage is to provide large amounts of information in an organized manner so that it can be accessed, managed, and updated. In a database, data can be organized into rows, columns, and tables. Different database storage systems can be used to store different types of content, such as bibliographic, full-text, digital, and / or image content. Furthermore, in computing, different database systems can be classified based on the organization method of the database. There are many different types of databases, including relational databases, distributed databases, cloud databases, object-oriented databases, and others.

[0006] Databases are used by various entities and companies to store information that may need to be accessed or analyzed. In an example, a retail company may store a list of all sales transactions in a database. The database may include information about when the transaction occurred, where the transaction occurred, the total cost of the transaction, identifiers and / or descriptions of all items purchased in the transaction, etc. The same retail company may also store, for example, employee information in the same database, which may include employee names, employee contact information, employee work history, employee compensation rates, etc. Depending on the needs of the retail company, employee information and transaction information may be stored in different tables in the same database. When a retail company wants to know the information stored in a database, it may need to "query" its database. The retail company may want to find data about, for example, the names of all employees who work at a specific store, all employees who work on a specific date, all transactions made for a specific product within a specific time frame, etc.

[0007] When a retail company wants to query its database to extract some organizational information from the database, a query statement is executed against the database data. The query returns specific data based on one or more query predicates, which indicate what information the query should return. The query extracts specific data from the database and formats the data into a readable form. Queries can be written in a language that the database can understand, such as structured query language ("SQL"), so that the database system can determine which data should be located and how the data should be returned. The query can request any relevant information stored in the database. If the appropriate data can be found to respond to the query, the database has the potential to reveal complex trends and activities. This functionality can only be exploited by using successfully executed queries.

[0008] However, in addition to the above example, a retail company may have database tables that store a large amount of information. Performing queries on very large tables may be challenging because a large amount of time and computing resources are required to scan the entire table. Therefore, it may be desirable to perform queries without scanning the entire table. In some implementations, queries can be performed by reading a materialized view that includes summary information about the table related to the query. Summary of the invention

[0009] Aspects of the present disclosure may be implemented in one or more of the following embodiments.

[0010] 1) A system comprising:

[0011] A computing service manager for managing internal operations of a cloud-based database platform;

[0012] a plurality of shared storage devices for jointly storing database data, wherein the plurality of shared storage devices are independent of the computing service manager; and

[0013] An execution platform including a plurality of execution nodes, wherein the execution platform is independent of the plurality of shared storage devices and the computing service manager;

[0014] Wherein, the computing service manager is configured to:

[0015] Generate materialized views based on source tables;

[0016] Merging the source table and the materialized view to generate a merged table, thereby identifying whether an update is performed on the source table that is not reflected in the materialized view; and

[0017] In response to detecting an update made to the source table that is not reflected in the materialized view, a task is assigned to one or more execution nodes of the execution platform to apply the update to the materialized view.

[0018] 2) The system according to 1), wherein the update comprises one or more of the following:

[0019] inserting one or more rows into the source table;

[0020] one or more rows deleted from the source table; or

[0021] One or more rows updated in the source table.

[0022] 3) The system according to 1), wherein the computing service manager is configured to allocate the task for applying the update to the materialized view in the following manner:

[0023] In response to determining that a new row has been inserted into the source table, assigning a task of refreshing the materialized view, the task comprising inserting the new row into the materialized view; and

[0024] In response to determining that a row has been deleted from the source table, assigning a task of compressing the materialized view includes deleting the row from the materialized view.

[0025] 4) The system according to 3), wherein the computing service manager is configured to: give priority to inserting the new row into the materialized view compared to deleting the row from the materialized view.

[0026] 5) The system according to 3), wherein the computing service manager is configured to assign the task of compressing the materialized view only after a plurality of rows are deleted from the source table so that the number of the plurality of rows exceeds a predetermined threshold number of deleted rows.

[0027] 6) The system according to 1), wherein the source table is organized into multiple micro-partitions, and wherein the update includes one or more of the following: new micro-partitions added to the source table, or micro-partitions deleted from the source table.

[0028] 7) The system according to 1), wherein the computing service manager is further configured to scan the merge table to detect one or more modified micro-partitions in the source table by:

[0029] Identify whether a new micro-partition is inserted into the source table that does not exist in the materialized view; or

[0030] The absence of a deleted micro-partition removed from the source table that still exists in the materialized view is identified.

[0031] 8) The system according to 1), wherein the computing service manager is further configured to redirect a query from the materialized view to the source table while applying the update to the materialized view.

[0032] 9) The system according to 1), wherein the computing service manager is further configured to generate a source table log, wherein the source table log includes:

[0033] a log of one or more rows inserted into the source table since the last refresh of the materialized view; and

[0034] A log of one or more rows deleted from the source table since the last compaction of the materialized view.

[0035] 10) The system according to 1), wherein the computing service manager is further configured to generate cost statistics information of the materialized view, wherein the cost statistics information includes one or more of the following:

[0036] the number of micro-partitions that have been materialized on the source table;

[0037] The total number of partitions on the source table;

[0038] The total number of partitions of the materialized view;

[0039] The number of queries accessing the materialized view; or

[0040] The number of times the query was accessed on the source table.

[0041] 11) A method comprising:

[0042] Generate materialized views based on source tables;

[0043] Merging the source table and the materialized view to generate a merged table, thereby identifying whether an update is performed on the source table that is not reflected in the materialized view; and

[0044] In response to detecting an update made to the source table that is not reflected in the materialized view, the update is applied to the materialized view.

[0045] 12) The method according to 11), wherein the updating comprises one or more of the following:

[0046] inserting one or more rows into the source table;

[0047] one or more rows deleted from the source table; or

[0048] One or more rows updated in the source table.

[0049] 13) The method according to 11), wherein applying the update to the materialized view comprises:

[0050] In response to determining that a new row has been inserted into the source table, refreshing the materialized view by inserting the new row into the materialized view; and

[0051] In response to determining that a row has been deleted from the source table, the materialized view is compressed by deleting the row from the materialized view.

[0052] 14) The method according to 13), wherein refreshing the materialized view by inserting the new row into the materialized view has a higher priority than compressing the materialized view by deleting the row from the materialized view.

[0053] 15) The method according to 13), wherein the materialized view is compressed only after it is detected that a plurality of rows are deleted from the source table such that the number of the plurality of rows exceeds a predetermined threshold number of deleted rows.

[0054] 16) The method according to 11), wherein the source table is organized into multiple micro-partitions, and wherein the update includes one or more of the following: new micro-partitions added to the source table, or micro-partitions deleted from the source table.

[0055] 17) The method according to 11) further comprises scanning the merge table to detect one or more modified micro-partitions in the source table by the following steps:

[0056] Identify whether a new micro-partition is inserted into the source table that does not exist in the materialized view; or

[0057] The absence of a deleted micro-partition removed from the source table that still exists in the materialized view is identified.

[0058] 18) The method according to 11) further includes redirecting a query from the materialized view to the source table while applying the update to the materialized view.

[0059] 19) The method according to 11) further includes generating a source table log, wherein the source table log includes:

[0060] a log of one or more rows inserted into the source table since the last refresh of the materialized view; and

[0061] A log of one or more rows deleted from the source table since the last compaction of the materialized view.

[0062] 20) The method according to 11) further includes generating cost statistics information of the materialized view, wherein the cost statistics information includes one or more of the following:

[0063] the number of micro-partitions that have been materialized on the source table;

[0064] The total number of partitions on the source table;

[0065] The total number of partitions of the materialized view;

[0066] The number of queries accessing the materialized view; or

[0067] The number of times the query was accessed on the source table.

[0068] 21) A processor capable of being configured to execute instructions stored in a computer-readable storage medium, the instructions comprising:

[0069] Generate materialized views based on source tables;

[0070] Merging the source table and the materialized view to generate a merged table, thereby identifying whether an update is performed on the source table that is not reflected in the materialized view; and

[0071] In response to detecting an update made to the source table that is not reflected in the materialized view, the update is applied to the materialized view.

[0072] 22) The processor according to 21), wherein the update comprises one or more of the following:

[0073] inserting one or more rows into the source table;

[0074] one or more rows deleted from the source table; or

[0075] One or more rows updated in the source table.

[0076] 23) The processor according to 21), wherein applying the update to the materialized view comprises:

[0077] In response to determining that a new row has been inserted into the source table, refreshing the materialized view by inserting the new row into the materialized view; and

[0078] In response to determining that a row has been deleted from the source table, the materialized view is compressed by deleting the row from the materialized view.

[0079] 24) The processor according to 23), wherein the instructions further comprise scanning the merge table to detect one or more modified micro-partitions in the source table by:

[0080] Identify whether a new micro-partition is inserted into the source table that does not exist in the materialized view; or

[0081] The absence of a deleted micro-partition removed from the source table that still exists in the materialized view is identified.

[0082] 25) The processor according to 21), wherein the instruction further comprises generating a source table log, wherein the source table log comprises:

[0083] a log of one or more rows inserted into the source table since the last refresh of the materialized view; and

[0084] A log of one or more rows deleted from the source table since the last compaction of the materialized view. BRIEF DESCRIPTION OF THE DRAWINGS

[0086] Non-limiting and non-exhaustive embodiments of the present disclosure are described with reference to the following drawings, wherein like reference numerals refer to the same or similar parts throughout the various views unless otherwise specified. The advantages of the present disclosure will be better understood with respect to the following description and drawings, wherein:

[0087] Figure 1 is a schematic block diagram showing components of a materialized view maintenance system according to an embodiment of the present disclosure;

[0088] Figure 2 is a schematic block diagram showing a process flow for updating a materialized view according to an embodiment of the present disclosure;

[0089] Figure 3 is a schematic block diagram showing a process flow for updating a materialized view according to an embodiment of the present disclosure;

[0090] Figure 4 is a schematic block diagram illustrating an example materialized view and associated micro-partitions of a source table according to an embodiment of the present disclosure;

[0091] Figure 5 is a schematic process diagram of a method for updating a materialized view according to an embodiment of the present disclosure;

[0092] Figure 6 is a schematic process diagram of a method for updating a materialized view according to an embodiment of the present disclosure;

[0093] Figure 7 is a block diagram showing a processing platform for a database system according to an embodiment of the present disclosure;

[0094] Figure 8 is a block diagram illustrating components of a computing service manager according to an embodiment of the present disclosure;

[0095] Fig. 9 is a block diagram illustrating components of an execution platform according to an embodiment of the present disclosure; and

[0096] Fig.10 is a schematic diagram of an example computing device according to an embodiment of the present disclosure.

[0097] Detailed Description

[0098] Disclosed herein are systems, methods, and apparatus for incrementally refreshing materialized views in a database system. The systems, methods, and apparatus disclosed herein improve database performance by ensuring that materialized views are up-to-date and not stale relative to their source tables. Materialized views can be used to speed up query performance and reduce the amount of storage required to respond to queries. Additionally, the systems, methods, and apparatus disclosed herein ensure that "internal" database tasks, such as refreshing materialized views, do not limit processing power used to execute "external" database tasks, such as client queries.

[0099] In an embodiment of the present disclosure, a method for maintaining a materialized view is disclosed. The method includes generating a materialized view based on a source table. The method includes merging the source table and the materialized view to detect an update of the source table that is not reflected in the materialized view. The update of the source table includes one or more of the following: adding, deleting, or updating a row in the source table since a previous refresh and / or a previous compression of the materialized view. The method includes, in response to detecting an update of the source table, applying the update to the materialized view.

[0100] In an embodiment, the method includes generating a materialized view based on a source table, wherein the source table is organized into a plurality of micro-partitions. The method includes merging the source table and the materialized view to generate the merged table. The method includes scanning the merged table to detect new micro-partitions that are not present in the materialized view that are inserted into the source table and scanning the merged table to detect the absence of deleted partitions that are removed from the source table and still present in the materialized view. The method includes detecting an update to the source table, wherein the update includes one or more of the following: a new partition that is inserted into the source table since a previous refresh of the materialized view, or a deleted partition that is removed from the source table since a previous compression of the materialized view. The method includes, in response to detecting the new micro-partition that is inserted into the source table, refreshing the materialized view by inserting the new micro-partition into the materialized view. The method includes, in response to detecting the deleted micro-partition that is removed from the source table, compressing the materialized view by removing the deleted micro-partition from the materialized view.

[0101] Databases are widely used for data storage and data access in computing applications. A database may include one or more tables that include or reference data that can be read, modified, or deleted using queries. However, for some modern data warehouse systems, executing queries may be particularly time-consuming and resource-intensive because modern data warehouse systems typically include tables that store petabytes of data. Querying very large databases and / or tables may require scanning large amounts of data. Reducing the amount of data scanned for database queries is one of the main challenges in data organization and processing. When processing queries against large amounts of data, it may be important to use materialized views to reduce the time and processing resources required to execute queries. The systems, methods, and devices disclosed herein provide devices for improving query performance by incrementally refreshing materialized views to ensure that materialized views are up-to-date, and can provide accurate information to be used in responding to queries.

[0102] A materialized view is a database object that includes the final or intermediate results of a database query. A materialized view can include a locally cached copy of database data, a subset of a table's rows or columns, the results of a join, the results of an aggregate function, and so on. A materialized view can be defined by a client or a system administrator and can include any appropriate information. Materialized views are often generated to help perform specific common queries.

[0103] A materialized view as disclosed in the present application is a declarative specification of persistent query results that are automatically maintained and transparently utilized. In an embodiment, a materialized view includes a local copy of remotely located data, or may include a subset of rows and / or columns of a source table or join result (which may be referred to as a "partition" or "micro-partition") or alternatively includes a summary using an aggregate function. A materialized view is generated by materialization, where query results are cached similar to the memory of function values ​​in a functional language. Materialized views improve the performance of expensive queries by materializing and reusing common intermediate query results in a workload. Materialized views are used to improve query performance, but at the expense of maintenance costs and increased storage requirements.

[0104] To help understand the present disclosure, an example implementation using materialized views is provided. An example client of the database platform is a marketing organization. In this example, the marketing organization stores a large amount of database data related to potential customers who may purchase goods or services advertised by the marketing organization. The marketing organization may store, for example, name, contact information, gender, socioeconomic status, and other information about each potential customer. The marketing organization may typically run advertising campaigns specific to different geographic regions. Because the marketing organization is interested in the location of its potential customers, the marketing organization may typically run queries to identify all potential customers in a specific city, state, or geographic region. For example, the marketing organization may request to know how many male potential customers and how many female potential customers there are in California, USA. Because the marketing organization often wants to know this information for different marketing campaigns, the marketing organization may define a materialized view for this information. The materialized view may give two summary numbers, one indicating the number of male potential customers in California and the other indicating the number of female potential customers in California. These numbers are determined based on the "source table" of the materialized view. The source table may be very large and may include information about every potential customer of the marketing organization. As the source tables are updated, the materialized view may become "stale" relative to the source tables, such that the materialized view no longer provides accurate numbers about the number of male and female potential customers in California. Therefore, it is necessary to ensure that the materialized view is refreshed relative to its source table so that the materialized view can be relied upon when performing database queries. It should be recognized that this example implementation is provided only to assist in understanding the present disclosure and should not limit the scope of the present disclosure. The materialized view can provide any suitable information and can be customized by customer account. The materialized view does not necessarily provide the aggregate information discussed in the example implementation, and can provide different information suitable for the needs of the customer account.

[0105] Materialized views can provide certain performance benefits for database operations. A materialized view can require a small amount of additional storage compared to the source table on which the materialized view is based. Materialized views can be automatically updated and maintained by the database system and can be used transparently without changing existing workloads on the source tables.

[0106] Before disclosing and describing methods, systems, and apparatus for maintaining materialized views, it should be understood that the present disclosure is not limited to the configurations, processing steps, and materials disclosed herein, as such configurations, processing steps, and materials may vary somewhat. It should also be understood that the terms used herein are only used to describe embodiments and are not intended to limit the scope of the present disclosure, as the scope of the present disclosure is limited only by the appended claims and their equivalents.

[0107] In describing and claiming the present disclosure, the following terminology will be used in accordance with the definitions set forth below.

[0108] It must be noted that, as used in this specification and the appended claims, the singular forms "a," "an," and "the" include plural referents unless the context clearly dictates otherwise.

[0109] As used herein, the terms "comprising," "including," "comprising," "characterized by," and grammatical equivalents thereof are inclusive or open-ended terms that do not exclude additional, unrecited elements or method steps.

[0110] As used herein, a database table is a collection of records (rows). Each record contains a collection of values ​​for table attributes (columns). Database tables are typically physically stored in multiple smaller (variable or fixed size) storage units, such as files or blocks.

[0111] As used herein, a micro-partition is an immutable storage device in a database table that cannot be updated in place and must be regenerated when the data stored therein is modified.

[0112] The applicant has developed systems, methods, and apparatus for low-cost incremental maintenance of materialized views. Such systems, methods, and apparatus provide maintenance of materialized views of a database in a low-cost manner, ensuring the freshness of the materialized views. In some embodiments, a customer account may indicate that a materialized view may be used only if the materialized view is "fresh" relative to its source table and includes correct and up-to-date data. Especially in very large data warehouses, it may be difficult and costly to maintain fresh materialized views for each data manipulation language (DML) operation. Because in some embodiments, materialized views may be very large and include many partitions or micro-partitions, the maintenance cost of materialized views is high and inefficient. Therefore, it may be challenging to achieve efficient use of materialized views because materialized views are expensive to maintain.

[0113] In an embodiment, a materialized view is consistently maintained and updated by incrementally refreshing the materialized view relative to its source table. Maintenance of the materialized view can be performed asynchronously, so that updates to the source table are decoupled from refreshing or compressing the materialized view. Disclosed herein are systems, methods, and apparatus for incremental and low-cost maintenance of materialized views, so that the materialized view is consistent with its source table and continuously refreshed in response to changes to the source table.

[0114] Some embodiments of the present disclosure may refer to "micro-partitioning" as storing a portion of data in a database table. The micro-partitions discussed herein may be considered as batch processing units, where each micro-partition has a continuous storage unit. For example, each micro-partition may contain between 50MB and 500MB of uncompressed data (note that the actual size in storage may be smaller because the data may be stored in compression). Row groups in a table may be mapped to separate micro-partitions organized in a columnar manner. This size and structure allow for extremely fine-grained selection of micro-partitions to be scanned, which may include millions or even hundreds of millions of micro-partitions. This fine-grained selection process may be referred to herein as metadata-based "pruning". Pruning involves using metadata to determine which parts of a table (including which micro-partitions or micro-partition groups in a table) are irrelevant to a query, and then avoiding those irrelevant micro-partitions when responding to queries and scanning, and only relevant micro-partitions can respond to queries. Metadata about all rows stored in a micro-partition may be automatically collected, including: the value range of each column in the micro-partition; the number of different values; and / or additional attributes for optimized and efficient query processing. In one embodiment, micro-partitioning may be automatically performed on all tables. For example, a table can be transparently partitioned using the sorting that occurs when inserting / loading data. However, it should be recognized that the micro-partitioning of the present disclosure is merely exemplary and should be considered non-limiting. It should be understood that the micro-partitioning may include other database storage devices without departing from the scope of the present disclosure.

[0115] Embodiments disclosed herein may be applied to data or tables in a database. Multiple database queries may be improved by maintaining fresh materialized views of source tables. Embodiments may include the ability to store query results so that query responses may include data directly from materialized views rather than from source tables. Materialized views may facilitate improved performance of complex joins by enabling fast retrieval of data through querying materialized views. Additionally, in a data warehouse, materialized views may pre-compute and store aggregated data to eliminate the overhead associated with expensive joins or aggregations for large or frequently used query categories. Materialized views may take snapshots of remote source tables and store local copies of remote data. Materialized views may also enable accounts to download subsets of data to mobile clients by periodically refreshing from a central server and propagating updates back to the central server by the client.

[0116] A detailed description of systems and methods consistent with various embodiments of the present disclosure is provided below. Although several embodiments are described, it should be understood that the present disclosure is not limited to any one embodiment, but includes many alternatives, modifications, and equivalents. In addition, although many specific details are set forth in the following description to provide a thorough understanding of the embodiments disclosed herein, some embodiments may be implemented without some or all of these details. In addition, for the sake of clarity, certain technical materials known in the prior art are not described in detail to avoid unnecessarily obscuring the present disclosure.

[0117] Now referring to the accompanying drawings, Figure 1 1 shows a schematic block diagram of a materialized view maintenance module 100. The materialized view maintenance module 100 includes a materialized view ("MV") generation component 102, a merge component 104, an update detection component 106, a refresh component 108, a compression component 110, and a statistics component 112. The materialized view maintenance module 100 communicates with a storage device 114, such as a database storage device.

[0118] The materialized view maintenance module 100 can be configured to implement automatic incremental refresh of materialized views associated with database source tables. For example, the MV generation component 102 can generate a materialized view based on a source table. The merge component 104 can update the materialized view and the source table so that the update detection component 106 can detect whether any updates have occurred on the source table that are not reflected in the materialized view. The refresh component 108 can refresh the materialized view by adding new rows that have been added to the source table since the previous refresh of the source table. The compression component 110 can remove rows from the materialized view that correspond to deleted rows removed from the source table since the previous compression of the source table. The statistics component 112 can generate statistics about the source table, the materialized view, and the incremental refresh of the materialized view.

[0119] The MV generation component 102 generates a materialized view based on a source table. The MV generation component 102 generates a materialized view to have its own domain and have the characteristics of a table and a view, and the view has additional information linked to the source table and version control information related to the source table. A materialized view is a declarative specification of a persistent query result that is automatically maintained and transparently used. A materialized view is a database object that includes the result of a persistent query result on a source table. A materialized view can be a local copy of data located remotely, it can be a subset of rows and / or columns of a source table or a connection result, or it can be a summary using an aggregate function. The MV generation component 102 can be configured to generate a materialized view by caching query results by a materialization process so that the cached query results are stored as a specific "materialized" table that can be updated from the original source table. A materialized view can improve the performance of database queries for large select, join, or aggregate statements. A materialized view provides additional storage that is smaller than a source table, a materialized view can automatically maintain a materialized view, and a materialized view can be used transparently without changing the existing workload on the source table. The materialized view includes additional information linked to its management, including a source table identifier, a set of micro-partitions that were materialized since the last refresh version of the materialized view, and a set of micro-partitions that were removed since the last compact version of the materialized view.

[0120] In an embodiment, the MV generation component 102 stores the same information as tables (e.g., tables) and views (e.g., view definitions) in the materialized view. In addition, the MV generation component 102 stores a source table identifier. The source table identifier is tagged to the materialized view during compilation to indicate the source table that will be used to maintain and incrementally update the materialized view. The MV generation component 102 also stores an indication of the type of the materialized view, where the type of the materialized view indicates an enumeration type (e.g., projection, summary, synopsis, join, etc.) used to determine the scope of the materialized view. In addition, the MV generation component 102 may include information specific to DML versioning that is added to the table version associated with the materialized view. The materialized view may be tagged with a previous refresh time and a previous compression time of the materialized view.

[0121] In an embodiment, the MV generation component 102 truncates the contents of the materialized view so that all micro-partitions are deleted and a full refresh is performed. This command may be required to support rewrite enhancements of the materialized view and may be implemented as a dedicated insert command generated from a structured query language (SQL) parser. In addition, a new subcommand may be added to the SQL DML to indicate that a truncation is required before starting an insert or refresh on the materialized view. The MV generation component 102 may generate the statement as two steps, including (1) truncation and (2) insert according to a subquery obtained from the definition of the materialized view.

[0122] The merge component 104 is configured to merge the materialized view and the source table. The merge component 104 merges (1) the micro-partitions of the materialized view filtered with a set of discarded micro-partitions with (2) the micro-partitions of the source table that have been added but not yet materialized. In an embodiment, the merging of the materialized view and the source table is similar to a local view expansion. The merge component 104 obtains a set of micro-partitions that have been added since a previous refresh of the source table, and further obtains a set of micro-partitions that have been removed since a previous compression of the source table. It should be appreciated that a micro-partition includes multiple rows, and without departing from the scope of the present disclosure, a micro-partition may be alternatively referred to as a row, for example, an added micro-partition may be referred to as a new row, and a removed micro-partition may be referred to as a deleted row.

[0123] The update detection component 106 is configured to detect updates to the source table that are not reflected in the materialized view. In an embodiment, the update detection component 106 is integrated with the merge component 104 and performs a scan on the materialized view when the materialized view is merged with the source table.

[0124] In an embodiment, the update detection component 106 detects updates to the source table by tracking changes based on a transaction log. The transaction log includes indications of micro-partitions / rows added to or removed from the source table. The transaction log distinguishes refreshes of the source table that add new micro-partitions / rows from refreshes of the source table that remove micro-partitions / rows from the source table. In an embodiment, the materialized view maintains two versions, including the most recent refresh version and the most recent compressed version. The update detection component 106 maintains a refresh construct that indicates a set of micro-partitions to be inserted into the materialized view by pulling a log of added micro-partitions added to the source table since the last refresh of the materialized view. The update detection component 106 maintains a compression construct that indicates a set of micro-partitions to be removed from the materialized view by pulling a log of micro-partitions removed from the source table since the last compression of the materialized view.

[0125] The refresh component 108 is configured to perform a refresh on the materialized view by adding one or more micro-partitions or new rows to the materialized view. The refresh component 108 receives an indication from the update detection component 108 that a micro-partition or row has been inserted into the source table since the last refresh of the materialized view. Then, the refresh component 108 inserts the micro-partition or row into the materialized view. The refresh component 108 can receive a single source table identifier for each materialized view it generates. The refresh component 108 inserts a given set of micro-partitions from the source table and updates the last refreshed version of the materialized view. In an embodiment, the refresh component 108 is manually triggered, enabled, or disabled by a user using a command. In an embodiment, when the refresh component 108 is enabled, the refresh component 108 automatically updates the materialized view.

[0126] In an embodiment, the refresh component 108 executes the insert command. The refresh component 108 receives a log of new micro-partitions added to the source table since the previous refresh of the materialized view. The refresh component 108 inserts the new micro-partitions into the materialized view and may be configured to group the new micro-partitions in the columns of the materialized view and sort the new micro-partitions in the materialized view. In an embodiment, the metadata for the new micro-partitions is consistent between the source table and the materialized view.

[0127] The compression component 110 is configured to perform compression on the materialized view by removing one or more micro-partitions or deleted rows from the materialized view. The compression component 110 receives an indication from the update detection component 106 that a micro-partition or row has been removed from the source table since the last compression of the materialized view. Then, the compression component 110 removes the micro-partition of the row from the materialized view. The compression component 110 may receive a single source table identifier for each materialized view it generates. The compression component 110 removes the source table micro-partition from the corresponding materialized view micro-partition to update the last compressed version of the materialized view. In an embodiment, the refresh component 108 has a higher priority than the compression component 110 because the compression of the materialized view may be particularly expensive and time-consuming. In an embodiment, the compression component 110 compresses the materialized view only after receiving a threshold number of rows, columns and / or micro-partitions removed from the source table since the previous compression of the materialized view. In such an embodiment, the compression component 110 will not operate after each removal operation on the source table, but only after the threshold number of removals has occurred on the source table.

[0128] In an embodiment, the compression component 110 executes the delete command. The compression component 110 receives a log of deleted micro-partitions that were deleted from the source table since the previous compression of the materialized view. The compression component 110 deletes the deleted micro-partitions from the materialized view. In an embodiment, access to the active file of the materialized view may be more efficient than access to the list of deleted micro-partitions.

[0129] In an embodiment, updates performed by either the refresh component 108 and the compression component 110 are automatically updated according to constraints received from the customer account. The customer account may indicate constraints on freshness and cost. The constraints may indicate the priority of the customer account to always keep the materialized view fresh or to prioritize cost and allow the materialized view not to be updated for a period of time. The system may automatically schedule refreshes or compressions of the materialized view based on the constraints received from the customer account. In an embodiment, the system provides visibility into the cost of updating the materialized view to the customer account.

[0130] The statistics component 112 maintains statistics about the freshness and usefulness of the materialized view. The statistics component 112 generates maintenance statistics about the freshness of the materialized view. Such maintenance statistics include the number of micro-partitions of the materialized source table, the total number of micro-partitions of the source table, and / or the total number of micro-partitions of the materialized view. The statistics component 112 generates usage statistics about the usefulness of the materialized view. Such usefulness statistics may include the number of queries accessing the materialized view and the number of queries accessing the source table.

[0131] The storage device 114 may include database storage and may be configured to store each of a plurality of database tables including a plurality of database files. The storage device 114 may include cache storage and / or long-term or slower retrieval storage.

[0132] In an embodiment, the work performed by the materialized view maintenance module 100 is performed in the background and can occur in a continuous manner. In an embodiment, once a materialized view is generated based on a source table, the materialized view maintenance module 100 is configured to maintain the freshness of the materialized view. In an embodiment, the maximum budget for materialized view maintenance can be changed by a customer account. A customer account can provide a large budget for maintenance operations for certain materialized views, but a smaller budget for other materialized views. A customer account can have access to multiple priority settings for maintenance operations for various materialized views. A customer account can also receive information indicating the frequency and efficiency of refreshing or compressing materialized views.

[0133] Figure 2 2 is a schematic block diagram of a process flow 200 for incremental update of a materialized view. The process flow 200 may be executed by any suitable computing device, including, for example, a computing service manager (see Figure 7-Figure 8 The computing service manager 702 in Figure 8100 in the materialized view). The process flow 200 includes creating a materialized view at 202, wherein the materialized view is based on a source table. The process flow 200 includes updating the source table at 204, which may include inserting new micro-partitions into the source table at 206 and / or removing deleted micro-partitions from the source table at 208. The process flow 200 includes querying the materialized view and the source table at 210. The query at 210 includes detecting whether any updates have occurred on the source table that are not reflected in the materialized view. For example, new micro-partitions may be added to source tables that have not yet been added to the materialized view. Deleted micro-partitions may be removed from source tables that remain in the materialized view. The process flow 200 includes applying updates to the materialized view at 212. Applying the updates 212 may include refreshing the materialized view by inserting new micro-partitions into the materialized view at 214, and / or compressing the materialized view by removing deleted micro-partitions at 216.

[0134] Figure 3 1 shows a schematic block diagram of an example process flow 300 for incremental update of a materialized view. The process flow 300 can be performed by any suitable computing device, including, for example, a computing service manager (see Figure 7-Figure 8 The computing service manager 702 in Figure 8 100 in ). The process flow 300 includes generating a materialized view based on a source table at 302. The process flow 300 includes updating the source table at 304, which may include inserting micro-partitions at 306 and / or removing micro-partitions at 308. The process flow includes querying the materialized view and the source table to detect any updates to the source table that are not reflected in the materialized view at 310. The process flow 300 includes applying the updates to the materialized view at 312.

[0135] exist Figure 3 In the example shown, a materialized view is generated by scanning a source table at 302. As shown, the source table includes a data set {1 2 3 4 5 6}. The corresponding materialized view includes data sets [1 (1 2 3)] and [2 (4 5 6)], which may indicate micro-partitions in a database, where a micro-partition is an immutable storage object in a database.

[0136] exist Figure 3 In the example shown, at 304, the source table is updated by adding (+7) and deleting (-2) (see Δ1). At 306, two micro-partitions are inserted into the source table by adding (+8) and adding (+9) (see Δ2). At 308, two micro-partitions are removed from the source table by removing (-1) and (-3) (see Δ3). As shown by Δ(delta), the overall update of the source table includes {+7+8+9-1-2-3}, which includes each of the individual updates made to the source table (see Δ1, Δ2, and Δ3).

[0137] exist Figure 3 In the example shown, the materialized view and the source table are queried at 310. Query 310 includes merging the materialized view and the source table. The source table is scanned and micro-partitions {7 8 9} are detected in the source table, but not in the materialized view. The materialized view is scanned and micro-partitions (1 2 3) are detected in the materialized view but not in the source table (1 23).

[0138] exist Figure 3 In the example shown, updates are applied to the materialized view at 312. The materialized view is scanned, and the system detects micro-partitions [1(1 2 3)] and [2(4 5 6)], and the system detects that micro-partition [1(1 2 3)] exists in the materialized view but should be removed. The system deletes micro-partition [1(1 2 3)], leaving micro-partition [2(4 5 6)]. The system scans the source table and finds micro-partition {7 8 9} and inserts the micro-partition into the materialized view, so that the materialized view includes micro-partitions [2(4 5 6)] and [3(7 8 9)].

[0139] Figure 4 4 shows an example micro-partition of a source table 402 and an example materialized view 404 generated based on the source table. The source table 402 is linearly transformed to generate multiple micro-partitions (see partition No. 7, partition No. 12, and partition No. 35). Figure 4 In one embodiment shown, multiple micro-partitions can generate a single micro-partition of the materialized view 404. A micro-partition is an immutable storage object in a database system. In an embodiment, the micro-partitions are represented as an explicit list of micro-partitions, and in some embodiments, this may be particularly expensive. In an alternative embodiment, the micro-partitions are represented as ranges of micro-partitions. In an embodiment, the micro-partitions are represented as DML versions that indicate the last refresh and last compression of the source table 402.

[0140] The example source table 402 is labeled as “source table No. 243” to illustrate that any number of source tables can be used to generate the materialized view 404, the materialized view 404 can index each of the multiple source tables (see the “Table” column in the materialized view 404), and / or any number of multiple materialized views can be generated for multiple possible source tables. Figure 4 As shown in the example embodiment in , the source table 402 includes three micro-partitions. The three micro-partitions of the source table 402 include the 7th partition, the 12th partition, and the 35th partition. Figure 4 It is shown that the micro-partitions are indexed under the “Partition” column in the materialized view 404 . Figure 4Also shown is materialized view 404 including a single micro-partition based on the three micro-partitions of source table 402. Additional micro-partitions may be added to and / or removed from materialized view 404 as materialized view 404 is incrementally updated.

[0141] like Figure 4 As shown, the metadata between source table 402 and materialized view 404 is consistent. The metadata of materialized view 404 is updated to reflect any updates to the metadata of source table 402.

[0142] Figure 5 A schematic flow chart of a method 500 for incremental update of a materialized view is shown. The method 500 can be performed by any suitable computing device, including, for example, a computing service manager 702, a materialized view maintenance module 100. The method 500 starts, and at 502 the computing device generates a materialized view based on a source table. At 504, the computing device merges the source table and the materialized view to detect an update to the source table that is not reflected in the materialized view. The method 500 causes the update of the source table to include one or more of the following: new rows inserted into the source table since a previous refresh of the materialized view, or deleted rows removed from the source table since a previous compression of the materialized view (see 506). The method 500 continues, and at 508, in response to detecting an update to the source table, the computing device applies the update to the materialized view.

[0143] Figure 6 A schematic flow chart of a method 600 for micro-partition-based updates of a materialized view is shown. The method 600 may be performed by any suitable computing device, including, for example, a computing service manager 702 or a materialized view maintenance module 100. The method 600 begins, and at 602, the computing device generates a materialized view based on a source table, wherein the source table includes a plurality of micro-partitions. The method 600 continues, and at 604, the computing device merges the source table and the materialized view to generate a merged table. At 606, the computing device scans the merged table to detect new micro-partitions inserted into the source table that do not exist in the materialized view. At 608, the computing device scans the merged table to detect the absence of deleted micro-partitions removed from the source table that still exist in the materialized view. The method 600 continues, and at 610, in response to detecting a new micro-partition inserted into the source table, the computing device refreshes the materialized view by inserting the new micro-partition into the materialized view. At 612 , in response to detecting the deleted micro-partition removed from the source table, the computing device compresses the materialized view by removing the deleted micro-partition from the materialized view.

[0144] Figure 7 700 is a block diagram depicting an example embodiment of a data processing platform 700. Figure 7As shown, the computing service manager 702 communicates with the queue 704, the customer account 708, the metadata 706, and the execution platform 716. In an embodiment, the computing service manager 702 does not receive any direct communication from the customer account 708, but only receives communication related to the job from the queue 704. In such an embodiment, the computing service manager 702 can be configured to perform only "internal" database tasks that do not include queries received from customer accounts. For example, such internal tasks may include re-clustering tables disclosed herein, updating materialized views, refreshing metadata, etc. In a specific embodiment, the computing service manager 702 can support any number of customer accounts, such as end users who provide data storage and retrieval requests, system administrators who manage the systems and methods described herein, and other components / devices that interact with the computing service manager 702. As used herein, the computing service manager 702 may also be referred to as a "global service system" that performs various functions as discussed herein.

[0145] The computing service manager 702 communicates with the queue 704. The queue 704 can provide jobs to the computing service manager 702 in response to a triggering event. One or more jobs can be stored in the queue 704 in a received order and / or priority order, and each of these one or more jobs can be transmitted to the computing service manager 702 for scheduling and execution. The queue 704 can determine the job to be executed based on the triggering event, such as the ingestion of data, the deletion of one or more rows in a table, the update of one or more rows in a table, the materialized view is out of date relative to its source table, the expression reaches a predefined clustering threshold indicating that the table should be re-clustered, etc. In an embodiment, the queue 704 includes entries for refreshing materialized views. The queue 704 may include entries for refreshing materialized views generated on local (i.e., local to the same account operating the computing service manager 702) source tables and / or entries for refreshing materialized views generated on shared source tables managed by different accounts.

[0146] The computing service manager 702 is also coupled to metadata 706, which is associated with the data stored in the entire data processing platform 700 as a whole. In some embodiments, the metadata 706 includes a summary of the data stored in the remote data storage system and the data available from the local cache. In addition, the metadata 706 can include information about how the data is organized in the remote data storage system and the local cache. The metadata 706 allows systems and services to determine whether a data segment needs to be accessed without having to load or access the actual data from the storage device.

[0147] In an embodiment, the computing service manager 702 and / or the queue 704 may determine that a job should be executed based on the metadata 706. In such an embodiment, the computing service manager 702 and / or the queue 704 may scan the metadata 706 and determine that a job should be executed to improve data organization or database performance. For example, the computing service manager 702 and / or the queue 704 may determine that a new version of a source table for a materialized view has been generated, and the materialized view has not yet been refreshed to reflect the new version of the source table. The metadata 706 may include a transactional change tracking stream that indicates the time when the new version of the source table was generated and the time when the materialized view was most recently refreshed. Based on the metadata 706 transaction stream, the computing service manager 702 and / or the queue 704 may determine that a job should be executed. In an embodiment, the computing service manager 702 determines that a job should be executed based on a triggering event, and stores the job in the queue 704 until the computing service manager 702 is ready to schedule and manage the execution of the job. In an embodiment of the present disclosure, the computing service manager 702 determines whether the table needs to be re-clustered based on the DML command being executed, wherein the DML command constitutes a trigger event.

[0148] The computing service manager 702 can receive rules or parameters from the customer account 708, and such rules or parameters can guide the computing service manager 702 to schedule and manage internal jobs. The customer account 708 can indicate that the internal job should only be executed at a specific time or should only utilize a set maximum number of processing resources. The customer account 708 can also indicate one or more triggering events that should prompt the computing service manager 702 to determine that the job should be executed. The customer account 708 can provide parameters about how many times a task can be re-executed and / or when the task should be re-executed.

[0149] The computing service manager 702 is also coupled to an execution platform 716, which provides a plurality of computing resources for performing various data storage and data retrieval tasks, as discussed in more detail below. The execution platform 716 is coupled to a plurality of data storage devices 712A, 712B, and 712N that are part of the storage platform 710. Although Figure 7 , but the execution platform 716 can communicate with any number of data storage devices. In some embodiments, the data storage devices 712A, 712B, and 712N are cloud-based storage devices located in one or more geographic locations. For example, the data storage devices 712A, 712B, and 712N can be part of a public cloud infrastructure or a private cloud infrastructure. The data storage devices 712A, 712B, and 712N can be hard disk drives (HDDs), solid state drives (SSDs), storage clusters, Amazon S3 TMStorage system or any other data storage technology. In addition, the storage platform 710 may include a distributed file system (such as Hadoop Distributed File System (HDFS)), an object storage system, etc.

[0150] In a particular embodiment, the communication links between the computing service manager 702, the queue 704, the metadata 706, the customer account 708 and the execution platform 716 are implemented via one or more data communication networks. Similarly, the communication links between the execution platform 716 and the data storage devices 712A-712N in the storage platform 710 are implemented via one or more data communication networks. These data communication networks can utilize any communication protocol and any type of communication medium. In some embodiments, the data communication network is a combination of two or more data communication networks (or subnetworks) coupled to each other. In an alternative embodiment, these communication links are implemented using any type of communication medium and any communication protocol.

[0151] like Figure 7 As shown, data storage devices 712A, 712B, and 712N are separated from computing resources associated with execution platform 716. This architecture supports dynamic changes to data processing platform 700 based on changing data storage / retrieval needs and changing needs of users and systems accessing data processing platform 700. Support for dynamic changes allows data processing platform 700 to expand rapidly in response to changing needs for systems and components within data processing platform 700. The separation of computing resources from data storage devices supports the storage of large amounts of data without requiring a corresponding large amount of computing resources. Similarly, this separation of resources supports a significant increase in computing resources used at a particular time without a corresponding increase in available data storage resources.

[0152] The computing service manager 702, queue 704, metadata 706, customer account 708, execution platform 716 and storage platform 710 are in Figure 7 704, metadata 706, customer accounts 708, execution platform 716, and storage platform 710. However, each of computing service manager 702, queue 704, metadata 706, customer accounts 708, execution platform 716, and storage platform 710 can be implemented as a distributed system (e.g., multiple systems / platforms distributed at multiple geographic locations). In addition, each of computing service manager 702, metadata 706, execution platform 716, and storage platform 710 can be scaled up or down (independently of each other) based on changes in requests received from queue 704 and / or customer accounts 708 and changing needs of data processing platform 700. Therefore, in the described embodiment, data processing platform 700 is dynamic and supports regular changes to meet current data processing needs.

[0153] During typical operation, the data processing platform 700 processes multiple jobs received from the queue 704 or determined by the computing service manager 702. These jobs are scheduled and managed by the computing service manager 702 to determine when and how to execute the job. For example, the computing service manager 702 can divide the job into multiple discrete tasks, and can determine what data is needed to execute each of the multiple discrete tasks. The computing service manager 702 can assign each of the multiple discrete tasks to one or more nodes of the execution platform 716 to process the task. The computing service manager 702 can determine what data is needed to process the task, and further determine which nodes within the execution platform 716 are most suitable for processing the task. Some nodes may have cached the data required for processing the task and are therefore good candidates for processing the task. Metadata 706 assists the computing service manager 702 in determining which nodes in the execution platform 716 have cached at least a portion of the data required for processing the task. One or more nodes in the execution platform 716 use the data cached by the node and the data retrieved from the storage platform 710 when necessary to process the task. It is desirable to retrieve as much data as possible from the cache within the execution platform 716 because the retrieval speed is generally much faster than retrieving data from the storage platform 710.

[0154] like Figure 7 As shown, the data processing platform 700 separates the execution platform 716 from the storage platform 710. In this arrangement, the processing resources and cache resources in the execution platform 716 operate independently of the data storage resources 712A-712N in the storage platform 710. Therefore, the computing resources and cache resources are not limited to specific data storage resources 712A-712N. Instead, all computing resources and all cache resources can retrieve data from and store data in any data storage resource in the storage platform 710. In addition, the data processing platform 700 supports adding new computing resources and cache resources to the execution platform 716 without making any changes to the storage platform 710. Similarly, the data processing platform 700 supports adding data storage resources to the storage platform 710 without making any changes to the nodes in the execution platform 716.

[0155] Figure 8 is a block diagram depicting an embodiment of a computing service manager 702. Figure 8As shown, the computing service manager 702 includes an access manager 802 and a key manager 804 coupled to a data storage device 806. The access manager 802 handles authentication and authorization tasks for the system described herein. The key manager 804 manages the storage and authentication of the key used during the authentication and authorization tasks. For example, the access manager 802 and the key manager 804 manage the key used to access the data stored in the remote storage device (e.g., the data storage device in the storage platform 710). As used herein, the remote storage device may also be referred to as a "permanent storage device" or a "shared storage device". The request processing service 808 manages the received data storage request and data retrieval request (e.g., a job to be executed on database data). For example, the request processing service 808 can determine the data used to process the received data storage request or data retrieval request. The data can be stored in a cache in the execution platform 716 (as discussed in more detail below), or can be stored in a data storage device in the storage platform 710. The management console service 810 supports administrators and other system managers to access various systems and processes. Additionally, management console service 810 may receive requests to execute jobs and monitor workload on the system.

[0156] The computing service manager 702 also includes a job compiler 812, a job optimizer 814, and a job executor 816. The job compiler 812 parses the job into multiple discrete tasks and generates execution code for each of the multiple discrete tasks. The job optimizer 814 determines the best method for executing the multiple discrete tasks based on the data that needs to be processed. The job optimizer 814 also handles various data pruning operations and other data optimization techniques to improve the speed and efficiency of executing the job. The job executor 816 executes the execution code of the job received from the queue 704 or determined by the computing service manager 702.

[0157] The job scheduler and coordinator 818 sends the received jobs to the appropriate service or system for compilation, optimization and dispatch to the execution platform 716. For example, the jobs can be prioritized and processed in this priority order. In an embodiment, the job scheduler and coordinator 818 determines the priority of internal jobs scheduled by the computing service manager 702 and other "external" jobs (such as user queries that can be scheduled by other systems in the database but can utilize the same processing resources in the execution platform 716). In some embodiments, the job scheduler and coordinator 818 identifies or assigns specific nodes in the execution platform 716 to handle specific tasks. The virtual warehouse manager 820 manages the operation of multiple virtual warehouses implemented in the execution platform 716. As described below, each virtual warehouse includes multiple execution nodes, and each execution node includes a cache and a processor.

[0158] In addition, the computing service manager 702 includes a configuration and metadata manager 822 that manages information related to data stored in remote data storage devices and local caches (i.e., caches in the execution platform 716). As discussed in more detail below, the configuration and metadata manager 822 uses metadata to determine which data micro-partitions need to be accessed to retrieve data for processing a particular task or job. The monitor and workload analyzer 824 oversees the processes executed by the computing service manager 702 and manages the distribution of tasks (e.g., workloads) across virtual warehouses and execution nodes in the execution platform 716. The monitor and workload analyzer 824 also reallocates tasks as needed based on the changing workload of the entire data processing platform 700, and further reallocates tasks based on user (i.e., "external") query workloads that can also be processed by the execution platform 826. The configuration and metadata manager 822 and the monitor and workload analyzer 824 are coupled to the data storage device 826. Figure 8 Data storage devices 806 and 826 in represent any data storage devices within data processing platform 700. For example, data storage devices 806 and 826 may represent caches in execution platform 716, storage devices in storage platform 710, or any other storage devices.

[0159] The computing service manager 702 also includes a materialized view maintenance module 100 as disclosed herein. The materialized view maintenance module 100 is configured to ensure that the materialized view is fresh with respect to its source table.

[0160] Fig. 9 is a block diagram depicting an embodiment of the execution platform 716. Fig. 9 As shown, the execution platform 716 includes multiple virtual warehouses, including virtual warehouse 1, virtual warehouse 2 and virtual warehouse N. Each virtual warehouse includes multiple execution nodes, and each execution node includes a data cache and a processor. The virtual warehouse can perform multiple tasks in parallel using multiple execution nodes. As discussed herein, the execution platform 716 can add new virtual warehouses and discard existing virtual warehouses in real time based on the current processing needs of the system and users. This flexibility allows the execution platform 716 to quickly deploy a large amount of computing resources when needed, without continuing to pay for them when those computing resources are no longer needed. All virtual warehouses can access data in any data storage device (for example, any storage device in the storage platform 710).

[0161] although Fig. 9 Each virtual warehouse shown in includes three execution nodes, but a particular virtual warehouse may include any number of execution nodes. In addition, the number of execution nodes in a virtual warehouse is dynamic, so that new execution nodes are created when there is additional demand, and existing execution nodes are deleted when they are no longer needed.

[0162] Each virtual warehouse has access to Figure 7 Thus, a virtual warehouse need not be assigned to a specific data storage device 712A-712N, but can access data from any data storage device 712A-712N within the storage platform 710. Similarly, Fig. 9 Each execution node shown in can access data from any data storage device 712A-712N. In some embodiments, a specific virtual warehouse or a specific execution node can be temporarily assigned to a specific data storage device, but the virtual warehouse or execution node can later access data from any other data storage device.

[0163] exist Fig. 9 In the example of , virtual warehouse 1 includes three execution nodes 902A, 902B and 902N. Execution node 902A includes cache 904A and processor 906A. Execution node 902B includes cache 904B and processor 906B. Execution node 902N includes cache 904N and processor 906N. Each execution node 902A, 902B and 902N is associated with processing one or more data storage and / or data retrieval tasks. For example, a virtual warehouse can handle data storage and data retrieval tasks associated with internal services (such as clustering services, materialized view refresh services, file compression services, storage procedure services, or file upgrade services). In other embodiments, a specific virtual warehouse can handle data storage and data retrieval tasks associated with a specific data storage system or a specific category of data.

[0164] Similar to the virtual warehouse 1 discussed above, virtual warehouse 2 includes three execution nodes 912A, 912B, and 912N. Execution node 912A includes a cache 914A and a processor 916A. Execution node 912N includes a cache 914N and a processor 916N. Execution node 912N includes a cache 914N and a processor 916N. In addition, virtual warehouse 3 includes three execution nodes 922A, 922B, and 922N. Execution node 922A includes a cache 924A and a processor 926A. Execution node 922B includes a cache 924B and a processor 926B. Execution node 922N includes a cache 924N and a processor 926N.

[0165] In some embodiments, with respect to data being cached by the execution node, Fig. 9The execution nodes shown are stateless. For example, these execution nodes do not store or otherwise maintain state information about the execution nodes or data cached by a particular execution node. Therefore, in the event of an execution node failure, the failed node can be transparently replaced with another node. Since there is no state information associated with the failed execution node, a new (replacement) execution node can easily replace the failed node without having to worry about re-forming a particular state.

[0166] although Fig. 9 The execution nodes shown each include a data cache and a processor, but alternative embodiments may include execution nodes that include any number of processors and any number of caches. In addition, the size of the cache may vary between different execution nodes. Fig. 9 The cache shown in stores data retrieved from one or more data storage devices in the storage platform 710 in a local execution node. Therefore, the cache reduces or eliminates the bottleneck problem that occurs in a platform that continuously retrieves data from a remote storage system. Instead of repeatedly accessing data from a remote storage device, the systems and methods described herein access data from a cache in an execution node, which is significantly faster and avoids the bottleneck problem discussed above. In some embodiments, the cache is implemented using a high-speed storage device that provides fast access to cached data. Each cache can store data from any storage device in the storage platform 710.

[0167] In addition, cache resources and computing resources can be different between different execution nodes. For example, an execution node can include a large amount of computing resources and a minimum of cache resources, so that the execution node can be used for tasks that require a large amount of computing resources. Another execution node can include a large amount of cache resources and a minimum of computing resources, so that the execution node can be used for tasks that require a large amount of data to be cached. Yet another execution node can include cache resources that provide faster input-output operations, which is useful for tasks that require rapid scanning of large amounts of data. In some embodiments, based on the expected tasks that the execution node will perform, the cache resources and computing resources associated with a specific execution node are determined when the execution node is created.

[0168] In addition, the cache resources and computing resources associated with a particular execution node may change over time based on changing tasks performed by the execution node. For example, if the tasks performed by the execution node become more processor intensive, more processing resources may be allocated to the execution node. Similarly, if the tasks performed by the execution node require greater cache capacity, more cache resources may be allocated to the execution node.

[0169] Although virtual warehouses 1, 2, and N are associated with the same execution platform 716, multiple computing systems at multiple geographic locations may be used to implement the virtual warehouses. For example, virtual warehouse 1 may be implemented by a computing system at a first geographic location, while virtual warehouses 2 and N may be implemented by another computing system at a second geographic location. In some embodiments, these different computing systems are cloud-based computing systems maintained by one or more different entities.

[0170] In addition, each virtual warehouse Fig. 9 1 is shown as having multiple execution nodes. Multiple computing systems at multiple geographic locations can be used to implement multiple execution nodes associated with each virtual warehouse. For example, an instance of virtual warehouse 1 implements execution nodes 902A and 902B on a computing platform at one geographic location, and implements execution node 902N at a different computing platform at another geographic location. The selection of a particular computing system to implement an execution node can depend on various factors, such as the resource level required for a particular execution node (e.g., processing resource requirements and cache requirements), the resources available at a particular computing system, the communication capabilities of a network within or between geographic locations, and which computing systems have implemented other execution nodes in the virtual warehouse.

[0171] The execution platform 716 is also fault-tolerant. For example, if a virtual warehouse fails, the virtual warehouse will be quickly replaced by a different virtual warehouse in a different geographical location.

[0172] A particular execution platform 716 may include any number of virtual warehouses. In addition, the number of virtual warehouses in a particular execution platform is dynamic, so that new virtual warehouses are created when additional processing and / or cache resources are needed. Similarly, existing virtual warehouses may be deleted when the resources associated with the virtual warehouses are no longer needed.

[0173] In some embodiments, virtual warehouses can operate on the same data in storage platform 710, but each virtual warehouse has its own execution node with independent processing and cache resources. This configuration allows requests on different virtual warehouses to be processed independently without interfering with each other. This independent processing, combined with the ability to dynamically add and remove virtual warehouses, supports adding new processing capabilities for new users without affecting the performance observed by existing users.

[0174] In an embodiment, different execution platforms 716 are assigned to different accounts in a multi-tenant database. This can ensure that the data stored in the caches of different execution platforms 716 is accessible only to the associated accounts. The size of each different execution platform 716 can be customized to accommodate the processing needs of each account in the multi-tenant database. In an embodiment, the provider account has its own execution platform 716, and the recipient account has its own execution platform 716. In an embodiment, the recipient account receives a shared object from the provider account, which enables the recipient account to generate a materialized view of the data owned by the provider account. The execution platform 716 of the recipient account can generate a materialized view. When the source table of the materialized view (i.e., the data owned by the provider account) is updated, the execution platform 716 of the provider account will perform the update. If the recipient account generates a materialized view, the execution platform 716 of the recipient account can be responsible for refreshing the materialized view relative to its source table.

[0175] Fig.10 1 is a block diagram depicting an example computing device 1000. In some embodiments, computing device 1000 is used to implement one or more of the systems and components discussed herein. In addition, computing device 1000 can interact with any of the systems and components described herein. Thus, computing device 1000 can be used to perform various procedures and tasks, such as those discussed herein. Computing device 1000 can act as a server, client, or any other computing entity. Computing device 1000 can be any of a variety of computing devices, such as a desktop computer, a notebook computer, a server computer, a handheld computer, a tablet computer, etc.

[0176] The computing device 1000 includes one or more processors 1002, one or more memory devices 1004, one or more interfaces 1006, one or more mass storage devices 1008, and one or more input / output (I / O) devices 1010, all coupled to a bus 1012. The processor 1002 includes one or more processors or controllers that execute instructions stored in the memory device 1004 and / or the mass storage device 1008. The processor 1002 may also include various types of computer-readable media, such as a cache.

[0177] The storage device 1004 includes various computer-readable media such as volatile memory (eg, random access memory (RAM)) and / or nonvolatile memory (eg, read-only memory (ROM)). The storage device 1004 may also include a rewritable ROM such as a flash memory.

[0178] The mass storage device 1008 includes various computer-readable media, such as magnetic tapes, magnetic disks, optical disks, solid-state memory (e.g., flash memory), etc. Various drives may also be included in the mass storage device 1008 to enable reading from and / or writing to various computer-readable media. The mass storage device 1008 includes removable media and / or non-removable media.

[0179] I / O devices 1010 include various devices that allow data and / or other information to be entered into or retrieved from computing device 1000. Example I / O devices 1010 include cursor control devices, keyboards, keypads, microphones, monitors or other display devices, speakers, printers, network interface cards, modems, lenses, CCD or other image capture devices, and the like.

[0180] Interfaces 1006 include various interfaces that allow computing device 1000 to interact with other systems, devices, or computing environments. Example interfaces 1006 include any number of different network interfaces, such as interfaces to a local area network (LAN), a wide area network (WAN), a wireless network, and the Internet.

[0181] The bus 1012 allows the processor 1002, memory device 1004, interface 1006, mass storage device 1008, and I / O device 1010 to communicate with each other and with other devices or components coupled to the bus 1012. The bus 1012 represents one or more of several types of bus structures, such as a system bus, a PCI bus, an IEEE 1394 bus, a USB bus, and the like.

[0182] For purposes of illustration, programs and other executable program components are shown herein as discrete blocks, although it should be understood that such programs and components may reside in different storage components of the computing device 1000 at different times and be executed by the processor 1002. Alternatively, the systems and procedures described herein may be implemented in hardware or a combination of hardware, software, and / or firmware. For example, one or more application specific integrated circuits (ASICs) may be programmed to perform one or more of the systems and procedures described herein. As used herein, the term "module" or "component" is intended to convey an implementation device for completing a process such as by hardware or a combination of hardware, software, and / or firmware to perform all or part of the operations disclosed herein. The term "module" or "component" is intended to be conveyed independently of how the module, component, or its function or hardware is implemented in different embodiments.

[0183] Example

[0184] The following examples relate to other embodiments.

[0185] Example 1 is a method for incrementally updating a materialized view. The method includes generating a materialized view based on a source table. The method includes merging the source table and the materialized view to detect an update of the source table that is not reflected in the materialized view. The update of the source table includes one or more of the following: new rows inserted into the source table since a previous refresh of the source table, or deleted rows removed from the source table since a previous compression of the source table. The method includes, in response to detecting the update of the source table, applying the update to the materialized view.

[0186] Example 2 is a method according to Example 1, wherein applying updates to the materialized view includes: in response to new rows inserted into a source table, refreshing the materialized view by inserting the new rows into the materialized view; and in response to deleted rows removed from the source table, compressing the materialized view by deleting rows corresponding to the deleted rows from the materialized view.

[0187] Example 3 is a method according to any one of Examples 1-2, wherein the update includes new rows inserted into the source table and deleted rows removed from the source table, and wherein inserting the new rows into the materialized view has a higher priority than deleting rows corresponding to the deleted rows from the materialized view.

[0188] Example 4 is a method according to any one of Examples 1-3, wherein rows are deleted from the materialized view only after it is detected that a number of deleted rows removed from the source table equals or exceeds a predetermined threshold number of deleted rows.

[0189] Example 5 is a method according to any one of Examples 1-4, wherein: refreshing the materialized view by inserting new rows into the materialized view includes executing a DML command on the materialized view; and compressing the materialized view by deleting rows corresponding to the deleted rows from the materialized view includes executing a DML command on the materialized view.

[0190] Example 6 is a method according to any one of Examples 1-5, wherein the source table includes one or more micro-partitions, and wherein: new rows inserted into the source table include new micro-partitions inserted into the source table; and deleted rows removed from the source table include deleted micro-partitions removed from the source table.

[0191] Example 7 is a method according to any one of Examples 1-6, wherein applying updates to the materialized view includes: in response to detecting a new micro-partition inserted into a source table, refreshing the materialized view by inserting the new micro-partition into the materialized view; and in response to detecting a deleted micro-partition removed from the source table, compressing the materialized view by deleting a set of micro-partition rows corresponding to the deleted micro-partition from the materialized view.

[0192] Example 8 is a method according to any one of Examples 1-7, wherein merging the source table and the materialized view includes generating a merged table, and wherein the method further includes scanning the merged table to detect one or more affected micro-partitions including one or more of the following: a new micro-partition inserted into the source table that does not exist in the materialized view; or the absence of a deleted micro-partition removed from the source table that still exists in the materialized view.

[0193] Example 9 is the method of any one of Examples 1-8, wherein the materialized view is inaccessible to the customer account before the update is applied to the materialized view.

[0194] Example 10 is a method according to any one of Examples 1-9, wherein: the source table includes a linear transformation, which includes multiple micro-partitions; the materialized view includes corresponding micro-partitions corresponding to the multiple micro-partitions of the source table; and the micro-partitions of the source table constitute immutable storage objects in the database storage system.

[0195] Example 11 is a method according to any one of Examples 1-10, further comprising generating a source table log, the source table log comprising: a log of one or more new rows inserted into the source table since a previous refresh of the source table; and a log of one or more deleted rows removed from the source table since a previous compression of the source table.

[0196] Example 12 is a method according to any one of Examples 1-11, further comprising maintaining two versions of the materialized view, wherein the two versions include: a last refreshed version of the materialized view, in which new rows are inserted into the materialized view; and a last compressed version of the materialized view, in which rows corresponding to deleted rows are removed from the materialized view.

[0197] Example 13 is a method according to any one of Examples 1-12, wherein the source table and the materialized view include metadata, and wherein the metadata of the source table and the materialized view are consistent.

[0198] Example 14 is a method according to any one of Examples 1-13, further comprising generating cost statistics, including: maintaining statistics including one or more of the following: the number of micro-partitions that have been materialized on the source table; the total number of micro-partitions on the source table; or the total number of partitions of the materialized view; and usage statistics including one or more of the following: the number of times a query is accessed on the materialized view; or the number of times a query is accessed on the source table.

[0199] Example 15 is a non-transitory computer-readable storage medium storing instructions that, when executed by one or more processors, cause the one or more processors to perform the following operations: generate a materialized view for a source table; merge the source table and the materialized view to detect updates to the source table that are not reflected in the materialized view, wherein the updates to the source table include one or more of the following: new rows that have been inserted into the source table since a previous refresh of the source table; or deleted rows that have been removed from the source table since a previous compression of the source table; and in response to detecting the update to the source table, apply the update to the materialized view.

[0200] Example 16 is a non-transitory computer-readable storage medium according to Example 15, wherein the instructions cause one or more processors to apply updates to a materialized view by: in response to a new row inserted into a source table, refreshing the materialized view by inserting the new row into the materialized view; and in response to detecting a deleted row removed from the source table, compressing the materialized view by deleting rows corresponding to the deleted row from the materialized view.

[0201] Example 17 is a non-transitory computer-readable storage medium according to any one of Examples 15-16, wherein the update includes new rows inserted into the source table and deleted rows removed from the source table, and wherein the instructions cause one or more processors to: insert new rows into the materialized view in preference to deleting rows corresponding to the deleted rows from the materialized view.

[0202] Example 18 is a non-transitory computer-readable storage medium according to any one of Examples 15-17, wherein: refreshing the materialized view by inserting new rows into the materialized view includes executing DML commands on the materialized view; and compressing the materialized view by deleting rows corresponding to the deleted rows from the materialized view includes executing DML commands on the materialized view.

[0203] Example 19 is a non-transitory computer-readable storage medium according to any one of Examples 15-18, wherein the instructions cause one or more processors to merge a source table and a materialized view to generate a merged table, and wherein the instructions also cause the one or more processors to scan the merged table to detect one or more affected rows, which include one or more of the following: new rows inserted into the source table that do not exist in the materialized view; or the non-existence of deleted rows removed from the source table that still exist in the materialized view.

[0204] Example 20 is a non-transitory computer-readable storage medium according to any one of Examples 15-19, wherein: the source table includes a linear transformation, which includes multiple micro-partitions; the materialized view includes corresponding micro-partitions corresponding to the multiple micro-partitions of the source table; and the micro-partitions of the source table constitute immutable storage objects in the database storage system.

[0205] Example 21 is a system for incrementally updating a materialized view. The system includes means for generating a materialized view for a source table. The system includes means for merging the source table and the materialized view to detect an update of the source table that is not reflected in the materialized view. The update of the source table includes one or more of the following: new rows inserted into the source table since a previous refresh of the source table or deleted rows removed from the source table since a previous compression of the source table. The system includes means for applying the update to the materialized view in response to detecting the update of the source table.

[0206] Example 22 is a system according to Example 21, wherein the device for applying updates to the materialized view is configured to: in response to new rows inserted into the source table, refresh the materialized view by inserting the new rows into the materialized view; and in response to deleted rows removed from the source table, compress the materialized view by deleting rows corresponding to the deleted rows from the materialized view.

[0207] Example 23 is a system according to any of Examples 21-22, wherein the update includes new rows inserted into the source table and deleted rows removed from the source table, and wherein the device for applying the update is configured to: add new rows to the materialized view in priority to deleting rows corresponding to the deleted rows from the materialized view.

[0208] Example 24 is a system according to any one of Examples 21-23, wherein the device for merging the source table and the materialized view is configured to generate a merged table, and wherein the system also includes a device for scanning the merged table to detect one or more affected micro-partitions including one or more of the following items: new rows inserted into the source table that do not exist in the materialized view; or the non-existence of deleted rows removed from the source table that still exist in the materialized view.

[0209] Example 25 is a system according to any one of Examples 21-24, wherein: the source table includes a linear transformation, which includes multiple micro-partitions; the materialized view includes corresponding micro-partitions corresponding to the multiple micro-partitions of the source table; and the micro-partitions of the source table constitute immutable storage objects in the database storage system.

[0210] Example 26 is a system or apparatus for implementing the method, system or apparatus according to any one of Examples 1-25.

[0211] Various technologies or some aspects thereof or parts thereof can be in the form of program code (i.e., instructions) contained in tangible media (such as, floppy disk, CD-ROM, hard disk drive, non-transitory computer-readable storage medium or any other machine-readable storage medium), wherein, when the program code is loaded into and executed by a machine such as a computer, the machine becomes a device for practicing various technologies. In the case of executing program code on a programmable computer, the computing device may include a processor, a storage medium (including volatile and non-volatile memory and / or storage element) readable by the processor, at least one input device and at least one output device. Volatile and non-volatile memory and / or storage element may be RAM, EPROM, flash memory, CD-ROM drive, magnetic hard disk drive or other media for storing electronic data. One or more programs that can implement or utilize various technologies described herein may use application programming interface (API), reusable controls, etc. These programs may be implemented with high-level programs, functions, object-oriented programming languages ​​to communicate with computer systems. However, if necessary, the program may be implemented with assembly language or machine language. In any case, the language may be a compiled or interpreted language and combined with a hardware implementation.

[0212] It should be understood that many of the functional units described in this specification can be implemented as one or more components, which is a term used to more specifically emphasize its implementation independence. For example, a component can be implemented as a hardware circuit that includes a customized very large scale integration (VLSI) circuit or gate array, an existing semiconductor (such as a logic chip, a transistor or other discrete component). The component can also be implemented in a programmable hardware device (such as a field programmable gate array, a programmable array logic, a programmable logic device, etc.).

[0213] Components may also be implemented in software so as to be executed by various types of processors. The components of the identified executable code may, for example, include one or more physical or logical blocks of computer instructions, which may, for example, be organized as objects, procedures, or functions. However, the executable files of the identified components need not be physically located together, but may include different instructions stored in different locations, which, when logically connected together, comprise the component and achieve the stated purpose of the component.

[0214] In fact, the components of executable code can be a single instruction or many instructions, and can even be distributed on several different code segments, different programs and several storage devices. Similarly, operating data can be identified and illustrated in the components herein, and can be implemented in any suitable form and organized in the data structure of any suitable type. Operating data can be collected as a single data set, or can be distributed on different locations including different storage devices, and can exist at least partially as electronic signals on a system or network. Components can be passive or active, including agents that can be operated to perform the desired function.

[0215] References throughout this specification to "an example" mean that a particular feature, structure, or characteristic described in conjunction with the example is included in at least one embodiment of the present disclosure. Therefore, the phrase "in an example" appearing in various places throughout this specification does not necessarily refer to the same embodiment.

[0216] As used herein, for convenience, multiple items, structural elements, constituent elements, and / or materials may be presented in a common list. However, these lists should be interpreted as if each member in the list were individually identified as an independent and unique member. Therefore, any individual member in such a list should not be interpreted as being in fact equivalent to any other member in the same list, based solely on its presentation in a common group without any indication to the contrary. In addition, various embodiments and examples of the present disclosure and alternatives to its various components may be referenced herein. It should be understood that these embodiments, examples, and alternatives should not be interpreted as de facto equivalents of each other, but should be regarded as separate and autonomous representations of the present disclosure.

[0217] Although the foregoing has been described in detail for the sake of clarity, it will be apparent that certain changes and modifications may be made without departing from the principles thereof. It should be noted that there are many alternative ways to implement the processes and devices described herein. Therefore, the present embodiment should be considered illustrative rather than restrictive.

[0218] Those skilled in the art will appreciate that many changes may be made to the details of the above-described embodiments without departing from the underlying principles of the present disclosure.

Claims

1. A system comprising: A computing service manager for managing internal operations of a cloud-based database platform; a plurality of shared storage devices for jointly storing database data, wherein the plurality of shared storage devices are independent of the computing service manager; and An execution platform including a plurality of execution nodes, wherein the execution platform is independent of the plurality of shared storage devices and the computing service manager; Wherein, the computing service manager is configured to: Generate a materialized view based on a source table, the source table including a set of micro-partitions, and the materialized view combines information in the set of micro-partitions in the source table into a single micro-partition in the materialized view; Merging the source table and the materialized view to generate a merged table, thereby identifying whether an update is performed on the source table that is not reflected in the materialized view, the update comprising one or more of: new one or more micro-partitions added to the set of micro-partitions in the source table, or one or more micro-partitions deleted from the set of micro-partitions in the source table; and In response to detecting an update made to the source table that is not reflected in the materialized view, assigning a task to one or more execution nodes of the execution platform to apply the update to the materialized view, wherein applying the update to the materialized view includes updating the single micro-partition in the materialized view corresponding to the set of micro-partitions in the source table to generate an updated materialized view.

2. The system according to claim 1, wherein: The update also includes one or more of the following: inserting one or more rows into the source table; one or more rows deleted from the source table; or One or more rows updated in the source table.

3. The system according to claim 1, wherein: The compute service manager is configured to allocate tasks for applying the update to the materialized view in the following manner: In response to determining that a new row has been inserted into the source table, assigning a task of refreshing the materialized view, the task comprising inserting the new row into the materialized view; as well as In response to determining that a row has been deleted from the source table, assigning a task of compressing the materialized view includes deleting the row from the materialized view.

4. The system according to claim 3, wherein: The computing service manager is configured to prioritize inserting the new row into the materialized view over deleting the row from the materialized view.

5. The system according to claim 3, wherein: The computing service manager is configured to assign the task of compressing the materialized view only after a plurality of rows are deleted from the source table such that the number of the plurality of rows exceeds a predetermined threshold number of deleted rows.

6. The system according to claim 1, wherein: The source table is organized into a plurality of micro-partitions.

7. The system according to claim 1, wherein: The computing service manager is further configured to scan the merge table to detect one or more modified micro-partitions in the source table by: Identify whether a new micro-partition that does not exist in the materialized view is inserted into the source table; or The absence of a deleted micro-partition removed from the source table that still exists in the materialized view is identified.

8. The system according to claim 1, wherein: The compute service manager is further configured to redirect queries from the materialized view to the source table while applying the update to the materialized view.

9. The system according to claim 1, wherein: The computing service manager is further configured to generate a source table log, wherein the source table log includes: a log of one or more rows inserted into the source table since the last refresh of the materialized view; and A log of one or more rows deleted from the source table since the last compaction of the materialized view.

10. The system according to claim 1, wherein: The computing service manager is further configured to generate cost statistics information of the materialized view, wherein the cost statistics information includes one or more of the following: the number of micro-partitions that have been materialized on the source table; The total number of partitions on the source table; The total number of partitions of the materialized view; The number of queries accessing the materialized view; or The number of times the query was accessed on the source table.

11. A method comprising: Generate a materialized view based on a source table, the source table including a set of micro-partitions, and the materialized view combines information in the set of micro-partitions in the source table into a single micro-partition in the materialized view; Merging the source table and the materialized view to generate a merged table, thereby identifying whether an update is performed on the source table that is not reflected in the materialized view, the update comprising one or more of the following: one or more new micro-partitions added to the set of micro-partitions in the source table, or one or more micro-partitions deleted from the set of micro-partitions in the source table; as well as In response to detecting an update made to the source table that is not reflected in the materialized view, applying the update to the materialized view includes updating the single micro-partition in the materialized view corresponding to the set of micro-partitions in the source table to generate an updated materialized view.

12. The method according to claim 11, wherein: The update also includes one or more of the following: inserting one or more rows into the source table; one or more rows deleted from the source table; or One or more rows updated in the source table.

13. The method according to claim 11, wherein: Applying the update to the materialized view includes: In response to determining that a new row has been inserted into the source table, refreshing the materialized view by inserting the new row into the materialized view; and In response to determining that a row has been deleted from the source table, the materialized view is compressed by deleting the row from the materialized view.

14. The method according to claim 13, wherein: Refreshing the materialized view by inserting the new row into the materialized view has a higher priority than compressing the materialized view by deleting the row from the materialized view.

15. The method according to claim 13, wherein: The materialized view is compressed only after detecting that a number of rows have been deleted from the source table such that the number of rows exceeds a predetermined threshold number of deleted rows.

16. The method according to claim 11, wherein: The source table is organized into a plurality of micro-partitions.

17. The method of claim 11, further comprising scanning the merge table to detect one or more modified micro-partitions in the source table by: Identify whether a new micro-partition is inserted into the source table that does not exist in the materialized view; or The absence of a deleted micro-partition removed from the source table that still exists in the materialized view is identified.

18. The method of claim 11, further comprising redirecting a query from the materialized view to the source table while applying the update to the materialized view.

19. The method according to claim 11, further comprising generating a source table log, wherein the source table log comprises: A log of one or more rows inserted into the source table since the last refresh of the materialized view; as well as A log of one or more rows deleted from the source table since the last compaction of the materialized view.

20. The method according to claim 11, further comprising generating cost statistics information of the materialized view, wherein the cost statistics information comprises one or more of the following: the number of micro-partitions that have been materialized on the source table; The total number of partitions on the source table; The total number of partitions of the materialized view; The number of queries accessing the materialized view; or The number of times the query was accessed on the source table.

21. A processor capable of being configured to execute instructions stored in a computer-readable storage medium, the instructions comprising: Generate a materialized view based on a source table, the source table including a set of micro-partitions, and the materialized view combines information in the set of micro-partitions in the source table into a single micro-partition in the materialized view; Merging the source table and the materialized view to generate a merged table, thereby identifying whether an update is performed on the source table that is not reflected in the materialized view, the update comprising one or more of the following: one or more new micro-partitions added to the set of micro-partitions in the source table, or one or more micro-partitions deleted from the set of micro-partitions in the source table; as well as In response to detecting an update made to the source table that is not reflected in the materialized view, applying the update to the materialized view includes updating the single micro-partition in the materialized view corresponding to the set of micro-partitions in the source table to generate an updated materialized view.

22. The processor of claim 21, wherein: The update also includes one or more of the following: inserting one or more rows into the source table; one or more rows deleted from the source table; or One or more rows updated in the source table.

23. The processor of claim 21, wherein: Applying the update to the materialized view includes: In response to determining that a new row has been inserted into the source table, refreshing the materialized view by inserting the new row into the materialized view; and In response to determining that a row has been deleted from the source table, the materialized view is compressed by deleting the row from the materialized view.

24. The processor of claim 23, wherein: The instructions also include scanning the merge table to detect one or more modified micro-partitions in the source table by: Identify whether a new micro-partition that does not exist in the materialized view is inserted into the source table; or The absence of a deleted micro-partition removed from the source table that still exists in the materialized view is identified.

25. The processor of claim 21, wherein: The instruction further includes generating a source table log, wherein the source table log includes: a log of one or more rows inserted into the source table since the last refresh of the materialized view; and A log of one or more rows deleted from the source table since the last compaction of the materialized view.

26. A method for incrementally updating a materialized view, comprising: Generate a materialized view based on a source table, the source table including a set of micro-partitions, and the materialized view combines information in the set of micro-partitions in the source table into a single micro-partition in the materialized view; Merging the source table and the materialized view to detect updates to the source table that are not reflected in the materialized view, the updates comprising one or more of: new one or more micro-partitions added to the set of micro-partitions in the source table, or one or more micro-partitions deleted from the set of micro-partitions in the source table; wherein the updates to the source table further comprise one or more of: new rows inserted into the source table since a previous refresh of the source table, or deleted rows removed from the source table since a previous compression of the source table; as well as In response to detecting an update to the source table, applying the update to the materialized view includes updating the single micro-partition in the materialized view corresponding to the set of micro-partitions in the source table to generate an updated materialized view.

27. The method according to claim 26, wherein: Applying updates to the materialized view includes: in response to new rows inserted into the source table, refreshing the materialized view by inserting new rows into the materialized view; and in response to deleted rows removed from the source table, compressing the materialized view by deleting rows from the materialized view corresponding to the deleted rows.

28. The method according to any one of claims 26-27, wherein: The updates include new rows inserted into the source table and deleted rows removed from the source table, and wherein inserting new rows into the materialized view takes precedence over deleting rows corresponding to deleted rows from the materialized view.

29. The method according to any one of claims 26-27, wherein: Rows are deleted from the materialized view only after detecting that a number of deleted rows removed from the source table equals or exceeds a predetermined threshold number of deleted rows.

30. The method according to any one of claims 26-27, wherein: Refreshing the materialized view by inserting new rows into the materialized view includes executing DML commands on the materialized view; And compressing the materialized view by deleting rows from the materialized view corresponding to the deleted rows includes executing a DML command on the materialized view.

31. The method according to any one of claims 26-27, wherein: The source table includes one or more micro-partitions, and wherein new rows inserted into the source table include new micro-partitions inserted into the source table; and deleted rows removed from the source table include deleted micro-partitions removed from the source table.

32. The method according to any one of claims 26-27, wherein: Applying updates to the materialized view includes: in response to detecting a new micro-partition inserted into the source table, refreshing the materialized view by inserting the new micro-partition into the materialized view; and in response to detecting a deleted micro-partition removed from the source table, compressing the materialized view by deleting a micro-partition row set corresponding to the deleted micro-partition from the materialized view.

33. The method according to any one of claims 26-27, wherein: Merging the source table and the materialized view includes generating a merged table, and wherein the method further includes scanning the merged table to detect one or more affected micro-partitions including one or more of the following: a new micro-partition inserted into the source table that does not exist in the materialized view; or the absence of a deleted micro-partition removed from the source table that still exists in the materialized view.

34. The method according to any one of claims 26-27, wherein: Until updates are applied to the materialized view, the customer account cannot access the materialized view.

35. The method according to any one of claims 26-27, wherein: The source table includes a linear transformation including a plurality of micro-partitions; the materialized view includes corresponding micro-partitions corresponding to the plurality of micro-partitions of the source table; and the micro-partitions of the source table constitute immutable storage objects in a database storage system.

36. The method according to any one of claims 26-27, further comprising generating a source table log, the source table log comprising: a log of one or more new rows inserted into the source table since a previous refresh of the source table; and a log of one or more deleted rows removed from the source table since a previous compaction of the source table.

37. The method according to any one of claims 26-27, further comprising maintaining two versions of the materialized view, wherein: The two versions include: a last refreshed version of the materialized view, in which new rows are inserted into the materialized view; and a last compressed version of the materialized view, in which rows corresponding to deleted rows are removed from the materialized view.

38. The method according to any one of claims 26-27, wherein: The source table and the materialized view include metadata, and wherein the metadata of the source table and the materialized view are consistent.

39. The method according to any one of claims 26-27, further comprising generating cost statistics, comprising: Maintaining statistical information, which includes one or more of the following: the number of micro-partitions that have been materialized on the source table; The total number of micro-partitions on the source table; or the total number of partitions of the materialized view; and the usage statistics include one or more of the following: the number of times queries are accessed on the materialized view; Or the number of times a query is accessed on said source table.

40. A non-transitory computer-readable storage medium storing instructions that, when executed by one or more processors, cause the one or more processors to: generating a materialized view for a source table, the source table comprising a set of micro-partitions, and the materialized view combines information in the set of micro-partitions in the source table into a single micro-partition in the materialized view; The source table and the materialized view are merged to detect updates to the source table that are not reflected in the materialized view, the updates comprising one or more of: new one or more micro-partitions added to the set of micro-partitions in the source table, or one or more micro-partitions deleted from the set of micro-partitions in the source table; wherein, The updates to the source table also include one or more of: new rows that have been inserted into the source table since a previous refresh of the source table; or deleted rows that have been removed from the source table since a previous compaction of the source table; as well as In response to detecting an update to the source table, applying the update to the materialized view includes updating the single micro-partition in the materialized view corresponding to the set of micro-partitions in the source table to generate an updated materialized view.

41. The non-transitory computer-readable storage medium of claim 40, wherein: The instructions cause the one or more processors to apply updates to the materialized view by: in response to a new row inserted into the source table, refreshing the materialized view by inserting the new row into the materialized view; And in response to detecting a deleted row removed from the source table, compressing the materialized view by deleting rows from the materialized view corresponding to the deleted row.

42. The non-transitory computer-readable storage medium of any one of claims 40-41, wherein: The updates include new rows inserted into the source table and deleted rows removed from the source table, and wherein the instructions cause one or more processors to prioritize inserting new rows into the materialized view over deleting rows corresponding to deleted rows from the materialized view.

43. The non-transitory computer-readable storage medium of any one of claims 40-41, wherein: Refreshing the materialized view by inserting new rows into the materialized view includes executing DML commands on the materialized view; And compressing the materialized view by deleting rows from the materialized view corresponding to the deleted rows includes executing a DML command on the materialized view.

44. The non-transitory computer-readable storage medium of any one of claims 40-41, wherein: The instructions cause one or more processors to merge the source table and the materialized view to generate a merged table, and wherein the instructions also cause the one or more processors to scan the merged table to detect one or more affected rows, the rows comprising one or more of: new rows inserted into the source table that do not exist in the materialized view; or the non-existence of deleted rows removed from the source table that still exist in the materialized view.

45. The non-transitory computer-readable storage medium of any one of claims 40-41, wherein: The source table includes a linear transformation including a plurality of micro-partitions; the materialized view includes corresponding micro-partitions corresponding to the plurality of micro-partitions of the source table; and the micro-partitions of the source table constitute immutable storage objects in a database storage system.

46. ​​A system for incrementally updating a materialized view, comprising: Means for generating a materialized view for a source table, wherein the source table includes a set of micro-partitions, and the materialized view combines information in the set of micro-partitions in the source table into a single micro-partition in the materialized view; means for merging the source table and the materialized view to detect updates to the source table that are not reflected in the materialized view, wherein the updates include one or more of: new one or more micro-partitions added to the set of micro-partitions in the source table, or one or more micro-partitions deleted from the set of micro-partitions in the source table; the updates also include one or more of: new rows inserted into the source table since a previous refresh of the source table, or deleted rows removed from the source table since a previous compression of the source table; and Means for applying an update to the materialized view in response to detecting an update to the source table, wherein applying the update to the materialized view comprises updating the single micro-partition in the materialized view corresponding to the set of micro-partitions in the source table to generate an updated materialized view.

47. The system of claim 46, wherein: The means for applying updates to the materialized view is configured to: in response to a new row inserted into the source table, refresh the materialized view by inserting the new row into the materialized view; And in response to the deleted row being removed from the source table, compressing the materialized view by deleting rows from the materialized view corresponding to the deleted row.

48. The system of any one of claims 46-47, wherein: The updates include new rows inserted into the source table and deleted rows removed from the source table, and wherein the means for applying the updates is configured to prioritize adding new rows to the materialized view over deleting rows corresponding to the deleted rows from the materialized view.

49. The system of any one of claims 46-47, wherein: The means for merging the source table and the materialized view is configured to generate a merged table, and wherein the system further comprises means for scanning the merged table to detect one or more affected micro-partitions including one or more of the following: new rows inserted into the source table that do not exist in the materialized view; or the absence of deleted rows removed from the source table that still exist in the materialized view.

50. The system of any one of claims 46-47, wherein: The source table includes a linear transformation including a plurality of micro-partitions; the materialized view includes corresponding micro-partitions corresponding to the plurality of micro-partitions of the source table; and the micro-partitions of the source table constitute immutable storage objects in a database storage system.