A scalable database system for querying time series data
Through dynamic partitioning and query-optimized super table block structure, it solves the shortcomings of existing database systems in high write rate and complex query support, achieves efficient storage and processing of time series data, and provides scalable query capabilities. and high reliability.
Patent Information
- Application Number
- CN202110318803.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-02-27
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2038-02-27
AI Technical Summary
It is difficult for existing database systems to effectively store and process time series data with high write rates, especially in application scenarios such as industry, agriculture, and the Internet of Things, and traditional systems have difficulty balancing complex query support and scalability.
By dynamically creating super-table blocks, using dimension attributes to partition the data, and determining storage blocks according to the recorded dimension attribute values, dynamic data partitioning and query optimization are achieved, SQL query language is supported, and the advantages of RDBMS and NoSQL databases are combined. Enable cluster upward and outward expansion.
It achieves efficient storage and processing of time series data, supports high write rates and complex queries, avoids the cost of defragmentation and index optimization in traditional systems, and provides scalable query capabilities and high reliability.
Smart Images

Figure CN113468232B_ABST
Abstract
Description
[0001] This application is a divisional application of the invention patent application with the application date of February 27, 2018, application number "201880014274.2", and invention name "Scalable database system for querying time series data".
[0002] CROSS-REFERENCE TO RELATED APPLICATIONS
[0003] This application claims the benefit of U.S. Provisional Application No. 62 / 464,289, filed on February 27, 2017, the entire contents of which are incorporated by reference. Background Art
[0004] The present disclosure relates generally to efficiently storing and processing data in a database system, and particularly to storing and processing time series data in a partitioned database system.
[0005] Time series data is generated and processed in several environments: monitoring and developer operations (DevOps), sensor data and the Internet of Things (IoT), computer and hardware monitoring, fitness and health monitoring, environmental and agricultural data, manufacturing and industrial control system data, financial data, logistics data, application usage data, etc. Typically, the amount of this data is large, for example, a single data source can generate data at a high rate, or many different sources can contribute data. In addition, the data is inherently complex, for example, a source can provide multiple measurements and tags associated with a single time. Since data is continuously collected, the amount of stored data typically increases over time. Analysis systems typically query this data to analyze the past, present, and future behavior of entities associated with the data. This analysis can be performed for a variety of reasons, including examining historical trends, monitoring current performance, identifying the root causes of current problems, and anticipating future problems, for example, for predictive maintenance. Therefore, operators are not inclined to delete this potentially valuable data.
[0006] Conventional systems cannot support the typical high write rates of many of these applications across industries. For example, in Internet of Things (IoT) settings including industry, agriculture, consumers, cities, or facilities, high write rates are caused by a large number of devices coupled with moderate to high write rates for each device. In a logistics setting, both planned data and actual data include time series that can be associated with each tracked object. Monitoring applications (e.g., in development and operations) can track many metrics per system component. Many forms of financial applications (e.g., financial applications based on stock or option market data) also rely on time series data. All of these applications require databases that can be extended to high ingestion rates.
[0007] Furthermore, beyond simply fetching or aggregating a single metric across a specific time period, these applications often query their data in complex and arbitrary ways. Such query patterns can involve rich predicates (e.g., complex joins in the WHERE clause), aggregations, statistical functions, windowing operations, joins (JOINs) against relational data, subqueries, common table expressions (CTEs), etc. However, these queries need to execute efficiently.
[0008] Therefore, storing time series data requires complex queries that scale and are efficient. Traditional technologies cannot achieve both of these characteristics in a single system. Users typically trade off between the horizontal scalability of "NoSQL" databases and the query capabilities of relational database management systems (RDBMS). Existing solutions for time series data require users to choose between scalability or rich query support.
[0009] Traditional relational database systems that support database query languages such as SQL (Structured Query Language) have difficulty handling high ingestion rates: they have poor write performance for large tables, and this problem gets worse over time as the amount of data grows linearly over time. In addition, any data deletion requires expensive "vacuuming" operations to defragment the disk storage associated with such tables. In addition, there is still a lack of out-of-the-box open source solutions for scaling out RDBMS across many servers.
[0010] Existing NoSQL databases are typically key-value or column-oriented databases. However, these databases often lack rich query languages or secondary index support, and suffer from high latency on complex queries. In addition, these databases often lack the ability to join data between multiple tables, and lack the reliability, tooling, and ecosystem of more widely used traditional RDBMS systems.
[0011] Distributed block or file systems avoid the need for a predefined data model or schema and scale easily by adding more servers. However, they pay the price for their simple storage model at query time, lacking the highly structured indexes required for fast and resource-efficient queries.
[0012] Nor can it support existing, widely used query languages such as SQL, but rather conventional techniques for creating new query languages, requiring both new training for developers and analysts and new client interfaces or connectors for integration with other systems. Summary of the invention
[0013] The above and other problems are solved by a computer-implemented method, computer system and computer-readable storage medium for dynamically creating a block for storing records being added to a hypertable representing a partitioned database table. An embodiment of the method includes receiving an insert request by a database system and processing the insert request. The insert request identifies a hypertable and one or more input records for inserting into the hypertable. Each record has multiple attributes including a dimension attribute set, and the dimension attribute set includes a time attribute. The hypertable is partitioned into multiple blocks based on the dimension attributes. The block is specified using a value set for each dimension attribute. For each record stored in the block, the value of each dimension attribute is mapped to a value from the value set of the dimension attribute. It is determined whether the input record should be stored in a new block or an existing block. For each new block being created, a value set corresponding to each dimension attribute is determined and a new block is created for storing the input record. The hypertable is updated by storing the input record in the new block. The data stored in the updated hypertable is processed in response to a subsequent query that identifies the hypertable.
[0014] An embodiment of a computer readable storage medium stores instructions for performing the steps of the above method for dynamically creating a block for storing records being added to a hypertable. An embodiment of a computer system includes one or more computer processors and a computer readable storage medium stores instructions for performing the steps of the above method for dynamically creating a block for storing records being added to a hypertable.
[0015] In view of storage reconfiguration of the database system, an embodiment of a computer-implemented method dynamically modifies a partitioning strategy of a database system storing a hypertable. The database system receives a first insert request for inserting one or more records in the hypertable. Each record has a plurality of attributes including a set of dimension attributes, the dimension attributes including a time attribute. The hypertable is partitioned into blocks along the set of dimension attributes, the blocks being distributed across a first plurality of locations. The records specified in the first insert request are stored in blocks created according to a first partitioning strategy. The first partitioning strategy specifies the size of the first plurality of blocks to be created and a mapping from each of the first plurality of blocks to a location from the first plurality of locations. Each record is inserted into a block determined based on the dimension attribute values of the record.
[0016] An indication to add one or more new locations to a database system is received so that the database system has a second plurality of locations. A second plurality of blocks is created after receiving the indication to add the one or more new locations. The second plurality of blocks is created according to a second partitioning strategy. The second partitioning strategy specifies the size of the second plurality of blocks to be created and a mapping from each of the second plurality of blocks to a location from the second plurality of locations. The first plurality of blocks continues to be stored according to the first partitioning strategy even after receiving the indication to add the one or more new locations. A second insert request is received after receiving the indication to add the one or more new locations. The records specified in the second insert request are stored in blocks determined based on the values of the dimension attributes of each record. Thus, the records may be stored in blocks stored according to the first partitioning strategy or in blocks stored according to the second partitioning strategy.
[0017] An embodiment of a computer-readable storage medium stores instructions for executing the steps of the above method for dynamically modifying a partitioning strategy of a database system for storing a hypertable. An embodiment of a computer system includes one or more computer processors and a computer-readable storage medium storing instructions for executing the steps of the above method for dynamically modifying a partitioning strategy of a database system for storing a hypertable.
[0018] The features and advantages described in this summary and the following detailed description are not all-inclusive.Many additional features and advantages will be apparent to one of ordinary skill in the art in view of the drawings, the specification, and the claims hereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The teachings of the embodiments can be readily understood by considering the following detailed description in conjunction with the accompanying drawings.
[0020] Figure 1 is a block diagram of a system environment in which a database system operates according to an embodiment.
[0021] Figure 2 Data partitioning of a database table according to an embodiment is shown.
[0022] Figure 3 Processing of queries in a database system including a plurality of database nodes according to an embodiment is shown.
[0023] Figure 4A The system architecture of the query processor according to the embodiment is shown.
[0024] Figure 4B A system architecture of a block management module according to an embodiment is shown.
[0025] Figure 5A process of inserting records into a hypertable stored across multiple database system nodes is shown according to an embodiment.
[0026] Figure 6 is a flow diagram of a process for executing a query for processing records stored in a hypertable, according to an embodiment.
[0027] 7 (A-C) illustrate data partitioning for a database table suitable for adding a location to a database system, according to an embodiment of the present invention.
[0028] Figure 8 A flow chart illustrating a process of modifying a data partitioning strategy of a database system in response to adding a new location to the database system, according to an embodiment, is shown.
[0029] Fig. 9 Selecting a partitioning strategy for creating chunks based on a temporal attribute of a record according to an embodiment is shown.
[0030] Fig.10 A flow chart illustrating a process of selecting a partitioning strategy for creating chunks based on temporal attributes of records according to an embodiment.
[0031] Fig.11 A partitioning strategy for creating chunks based on the time at which a record is received by a database system is shown according to an embodiment.
[0032] Fig.12 The architecture of a computer that can be used to implement a database system node according to an embodiment is shown. DETAILED DESCRIPTION
[0033] Embodiments of the present invention include a database system that supports standard query languages such as SQL and exposes an interface based on a hypertable for partitioning underlying data across servers and / or storage devices. The database system enables users to interact with data as if the data were stored in a conventional database table, thereby hiding the complexity of any data partitioning and query optimization from the user. The implementation of the database system makes query languages such as SQL scalable for time series data. The database system combines the best features of RDBMS and NoSQL databases: clustered scale-up and scale-out architectures and rich support for complex queries. Scaling up corresponds to running on a larger separate server, for example, a machine with a large number of CPUs or cores, or a server with greater RAM and disk capacity. Scaling up also includes increasing the storage capacity of an existing database system by adding additional storage devices. Scaling out includes increasing the storage capacity of a database system by adding additional servers, for example, by sharding a data set on multiple servers and supporting parallel and / or concurrent requests across multiple servers.
[0034] System environment
[0035] Figure 1 1 is a block diagram of a system environment in which a database system operates according to an embodiment. The system environment includes a database system 110, one or more client devices 120, and a network 115.
[0036] The database system 110 includes a query processor 130, a metadata storage device 140, and a data storage device 145. Figure 2 As shown, for example, the database system 110 may include other components. The database system 110 receives database queries, such as queries specified using SQL, and processes the database queries. The database system 110 may support standard SQL features as well as new user-defined functions, SQL extensions, or even non-SQL query languages, such as declarative programming languages, REST interfaces (e.g., via HTTP), or others.
[0037] The data storage device 145 stores data as tuples (also called records) that can be stored as data rows, where each row includes a set of attributes. These attributes typically have names associated with them (e.g., "time", "device_id", "location", "temperature", "error_code") and types (e.g., string, integer, floating point number, Boolean, array, json, jsonb (binary json), blob, geospatial, etc.), but this is not necessary in all cases. The terms "field", "column", or "key" may also be used herein to refer to an attribute.
[0038] The data storage device 145 can store records in a standard database table that uses conventional techniques used by relational database systems to store data in one or more files. The data storage device 145 can also store data in a partitioned database table called a hypertable. A hypertable is an interface that provides a single continuous table represented by a virtual view so that a requester can query its partitioned database table through a database query language such as SQL. A standard schema with attribute (or field or column) names and types can be used to define a hypertable, wherein at least a time attribute specifies a time value. A hypertable is partitioned along a set of dimensional attributes that include a time attribute and zero or more other dimensional attributes (sometimes referred to as the "space" attribute of a hypertable). These dimensional attributes that partition a hypertable are also referred to as "partitioning keys", "partition keys" or "partition fields". A hypertable can be created using standard SQL commands for creating a database table. In addition, a database query such as an SQL query can be used to query a hypertable.
[0039] The database system divides the hypertable into chunks. Each chunk stores a subset of the records of the hypertable. Chunks may also be referred to herein as data chunks or partitions. The database system 110 may distribute chunks of the hypertable across a collection of one or more locations. A location may represent a storage medium for storing data or a system including a storage medium for storing data, such as a server. The storage medium may be a storage device, such as a disk. The database system 110 may store data on multiple storage devices attached to the same server or on multiple servers, each server being attached with one or more storage devices for storing chunks. The storage device may be attached to a remote server in a cloud-based system, for example, and a server of the database system that is provided with access to the remote storage device for storing chunks.
[0040] The database system can store multiple hypertables, each with different modes. Blocks within the same hypertable usually have the same mode, but can also have different modes. The database system can also include standard database tables, i.e., traditional non-partitioned tables stored in the same database. Operations are performed on any of these tables including multiple tables in a single query. For example, this can involve the selection (SELECT) of connecting (JOIN) data between a hypertable and a standard non-partitioned table, or between two hypertables, or any more complex combination thereof. Alternatively, it can involve inserting data into a hypertable and a standard non-partitioned table, or between two hypertables, or a more complex combination as a single transaction.
[0041] In some embodiments, the database system 110 includes one or more database system nodes (also referred to as database servers or just servers) connected via a network. Each node may include Figure 1 The same or similar components, such as query processor 130, metadata storage device 140 and data storage device 145. Figure 2 The details of the database system nodes are described in . Metadata storage 140 stores metadata describing the data stored in data storage 145, including descriptions of various hypertables and standard non-partitioned tables. The description includes various attributes of each table, descriptions of various blocks of the hypertable, etc. As further described herein, query processor 130 receives queries and processes them.
[0042] The database system 110 may be connected to requestors that issue database queries to the database system 110. The requestor may be any source of a database query, such as a client device 120, a network server, an application server, a user workstation, or a server or machine that sends a query on behalf of another origin (e.g., an intermediate server or middleware layer that acts as a queue, buffer, or router such as for INSERT, or an application on behalf of another system or user).
[0043] The connection from the requester usually occurs through the network 115, but it can also be on the same server executing the database system. For example, the network 115 enables communication between the client device 120 or any other requester and the database system 110. In one embodiment, the network uses standard communication technologies and / or protocols. The data exchanged through the network can be represented using technologies and / or formats including: open database connectivity (ODBC) format, Java database connectivity (JDBC) format, PostgreSQL external data wrapper (FDW) format, PostgreSQL dblink format, external data representation (XDR) format, Google protocol buffer (protobuf) format, Apache Avro format, Hypertext Markup Language (HTML), Extensible Markup Language (XML), Javascript Object Notation (JSON), etc.
[0044] The client device 120 may be a personal computer (PC), a desktop computer, a laptop computer, a notebook, a tablet PC executing an operating system. In another embodiment, the client device 120 may be any device having computer functionality, such as a personal digital assistant (PDA), a mobile phone, a smart phone, a wearable device, etc. The client device may also be a server or workstation running in a background environment, in an enterprise data center, or in a virtualized cloud data center. The client device executes a client application for interacting with the database system 110, such as a browser 125, a database shell, a web service application (e.g., .NET, Djagno, Ruby-on-Rails, Hibernate), a message broker (e.g., Apache Kafka or RabbitMQ), a visualization application, etc.
[0045] Figure 1 The same reference numerals as in other figures are used to identify the same elements. A letter following a reference numeral, such as "120A," indicates that the text refers specifically to the element with that particular reference numeral. A reference numeral in the text without a subsequent letter, such as "120," refers to any or all elements in the figures bearing that reference numeral (e.g., "120" in the text refers to reference numerals "120A" and / or "120N" in the figures).
[0046] Figure 2 The partitioning of data into blocks of a hypertable according to an embodiment is shown. Each of these blocks corresponds to a portion of the entire data set organized according to some partitioning function involving one or more of the attributes of the records. The attributes of the records used to partition the hypertable into blocks are called dimension attributes. Thus, a block corresponds to an "n-dimensional" partitioning of the hypertable (for n ≥ 1).
[0047] The database system 110 may implement the chunks as files. In one embodiment, each chunk is implemented using a standard database table that is automatically placed on one of the locations (e.g., storage devices) of one of the database nodes (or replicated between multiple locations or nodes), although this detail may not be observable to the user. In other embodiments, the placement of chunks on locations and / or database nodes is specified by commands or policies given by a database administrator or user.
[0048] One of the dimension attributes is a time attribute that stores time-related values. The time attribute can be any data that can be comparable (i.e., with > and ≥ operators) so that the data can be sorted according to the comparison function. In addition, new records are typically associated with a higher time attribute so that the value is typically increasing for new records. Note that this value can be specified in the data record and does not need to (and typically does not) correspond to when the data was inserted into the database. The following values can be used as time attributes: date timestamps (including with or without time zone information), UNIX timestamps (in seconds, microseconds, nanoseconds, etc.), sequence numbers, etc. In an embodiment, the hypertable is also segmented along dimension attributes representing different identifiers of objects or entities described in the database table (e.g., a device id that identifies a device, a server id that identifies a server, a stock code of a financial security, etc.).
[0049] A block is associated with a value set corresponding to each dimension attribute. For example, a hypertable may have two dimension attributes d1 and d2. For a given block C1, dimension attribute d1 is associated with value set SI, and dimension attribute d2 is associated with value set S2. Therefore, each record stored in block C1 has a dimension attribute value that maps to a value in the value set corresponding to the dimension attribute. For example, assume that a hypertable includes attributes time, equipment, and temperature. Also assume that time is a dimension attribute and that a block is associated with a time range [0:00:00 to 11:59:59.999]. If an input record has a value {time: "1:00:00", equipment: "A", temperature: 65}, the block can store the input record because the value "1:00:00" of the time dimension falls within the range associated with the block, i.e., [0:00:00 to 11:59:59.999].
[0050] The value set corresponding to the dimension attribute can represent a range of values, but is not limited to a range. For example, the value set can represent multiple discontinuous ranges. Alternatively, the value set can be specified by enumerating one or more values. For example, the dimension attribute cl can represent a color (e.g., "red", "blue", "green", "yellow"), and a block can store records with values of the dimension attribute cl from the set {"red", "blue"} and another block can store records with values of the dimension attribute cl from the set {"green", "yellow"}.
[0051] A given value of a dimension attribute can be mapped to a value in the value set corresponding to the dimension if the given value is the same as a value in the value set. Alternatively, a given value v1 of a dimension attribute can be mapped to a value v2 in the value set corresponding to the dimension if a value v2 is obtained by applying a transformation (e.g., a function) to a given value v1. For example, the database system 110 can use a hash partitioning strategy in which a value set corresponding to a dimension is specified as a range / set of values obtained by applying a hash function to the dimension attribute value. Thus, if a dimension attribute value is represented as vx, and H represents a hash function, a block Cx can be associated with a range R = [x1, x2] (or set) of values of H(vx). Thus, if H(v1) is in the range [x1, x2], the block can store records with a dimension attribute value v1.
[0052] In an embodiment, a value set may correspond to multiple dimension attributes. For example, the hash function specified in the above example may receive two or more inputs, each corresponding to a different dimension attribute, i.e., H(v1, v2, ...). Thus, the dimension of a block may be defined as a composite attribute comprising multiple dimension attributes of a hypertable.
[0053] Figure 2 A hypertable 160 is shown that is partitioned into multiple blocks 210 along two dimensional attributes, a time attribute and another dimensional attribute called a spatial attribute. In this example, each block is associated with a time range that includes a start time and an end time, and the spatial range includes a continuous range of alphabetic characters. For example, block 210a stores a set of records with values of the time attribute in the range [0,6] and values of the spatial attribute in the range [A,I]. Similarly, block 210b stores a set of records with values of the time attribute in the range [0,6] and values of the spatial attribute in the range [J,R], and so on.
[0054] Different types of queries can be made against a hypertable, including those that only read from the hypertable (e.g., database SELECT statements), and those that modify the hypertable (e.g., database INSERT, UPDATE, UPSERT, and DELETE statements). Writes are typically sent in chunks consisting of the most recent time interval (but need not be the most recent time interval), while queries can be cut across multiple dimensional attributes such as both time and space.
[0055] Although hypertables and blocks are referred to as tables in this article, the term is not meant to be limiting, and blocks can refer to several storage representations, including traditional relational database tables, virtual database views, materialized database views, structured markup language (e.g., XML) sets, serialized structured data sets (e.g., JSON, Google Protocol Buffers, Apache Avro, Apache Parquet), or flat files (e.g., with comma- or tab-separated values).
[0056] Distributed query execution
[0057] Figure 3 The processing of queries in a database system including multiple database nodes according to an embodiment is shown. The database system node 310a receives database queries and can send one or more queries to blocks (which can be implemented as physical tables of data) stored on the coordinator database system node or other database system nodes. If the database system node determines that a block is not needed to satisfy the query, the database system node does not issue a query to the block. The determination uses additional metadata about the block, which can be kept separate from or together with the data of each block. Each database system node can also keep additional metadata to enable it to effectively determine the time interval of the block and the key space of the partition field. The database system can keep the metadata separate from the block or together with the block.
[0058] like Figure 3 As shown, database system node 310a receives a first database query 320. Database system node 310a determines that the data required to process the received database query is on one or more database system nodes 310a, 310b, and 310c. Database system node 310a also sends queries 325a and 325b for processing the first query to database system nodes 310b and 310c, respectively. All three database system nodes 310a, 310b, and 310c use one or more data blocks stored on their respective nodes to process their respective queries. Figure 3In the example shown, if database system node 310a determines that the data required to process the first query is only stored on database system nodes 310a and 310b and not stored on 310c, then database system node 310a sends the query for processing to 310b instead of 310c. In other embodiments of the system, the queries 325a and 325b sent to other nodes 310b and 310c are the same as the first query 320, and the queries or requests sent to other nodes may use a different query language, format or communication protocol than the first query. In some embodiments of the system, queries 325a and 325b may be the same as each other, while in other embodiments they are different. In addition, in other embodiments, node 310a does not store blocks itself, but only processes query 320 and issues corresponding queries 325 to other database nodes.
[0059] The database system node 310a receiving the database query may determine that the query to the hypertable does not involve data for a particular block—for example, because the query specifies a time period that is different from the time period associated with the block, or if the query specifies a dimensional attribute associated with a different block (e.g., an IP address, a device ID, or some location name). In this case, the first database system node does not issue the query to the particular block (which may be located on the first database node itself or on a different node). This determination by both the first database system node and any other database system nodes may be performed by the query processor 130 present on each database system node that processes the query.
[0060] Any database system node can receive a query from a requester and a query processor 130 running on that database system node determines how to plan and execute the query across the entire cluster of one or more nodes. The database system node sends a query (a "subquery") to zero or more other nodes in the system. Subsequently, the database system node that receives the subquery from the first database system node includes a query processor 130 that determines how to plan and execute the query locally.
[0061] In an embodiment, this process is extended to additional levels of subqueries and involved planners. In an embodiment, the database system performs this partitioning recursively. For example, a block stored on one of the nodes may itself be further partitioned in time and / or by additional partitioning keys (same or different than the partitioning keys of a higher level), the block itself may be distributed among nodes (e.g., on different disks) or even distributed to other nodes. In such a case, the block may act as an additional hypertable.
[0062] In some embodiments, the database system performs query processing using only the query processor 130 on the first database system node. Thus, the entire query plan is generated by the first node and sent to the node determined to store the chunks processed by the query. The remaining nodes that receive the query plan (or a portion thereof) simply execute the received query plan without having to generate a portion of the query plan. In other embodiments, the database system implements less uniform functionality across nodes, such that a first set of one or more nodes receives the query and the query is planned and executed against a second, disparate set of one or more nodes storing the chunks.
[0063] System Architecture
[0064] Figure 4A The system architecture of the query processor according to the embodiment is shown. The query processor 130 includes the following components, including a connector 410, a query parser 415, a query planner 425, a query optimizer 430, an execution engine 435, and a query plan storage device 455. The query processor 130 receives a query in a query language such as SQL, which specifies a table or data set to which the query is to be applied (i.e., read or write data). A query or database query can represent a request to read data from a database (e.g., a select statement in SQL) or to modify data (e.g., insert, update, and delete statements in SQL).
[0065] The query parser receives the request and converts it into a query representation that is easier to process. For example, the query parser 415 can generate a data structure representing the query that provides access to the information specified in the query. The query optimizer 430 performs the conversion of the query, such as by rewriting parts of the query to improve the execution of the query. The query planner uses this machine-readable representation of the query, which is usually declarative in nature, and generates a plan that specifies how the query should be executed for the stored data, which can be stored in a memory (e.g., RAM, PCM) and / or on some type of non-volatile storage medium (e.g., flash SSD, HDD). The query processor 130 stores the generated plan in the query plan storage device 455. The execution engine 435 executes the query for the stored data and returns the result to the requester. The connector 410 enables the query processor 130 to connect to a remote system, for example, to access data stored in the remote system.
[0066] Figure 4BThe system architecture of the block management module according to the embodiment is shown. The block management module 170 also includes a block selection module 445 and a block creation module 450. The block selection module 445 implements a block selection function that determines a block for storing a given record. The block selection module 445 determines whether an existing block can be used to store a record. If the block selection module 445 determines that none of the existing blocks can be used to store a record, the block selection module 445 determines that a new block needs to be created and calls a block creation module 450 for creating a block. If the block selection module 445 determines that a new block needs to be created, the block selection module 445 determines various parameters that describe the new block. For example, the block creation module 450 determines a value set of different dimensional attributes corresponding to the record that define the block boundary. Therefore, the records stored in the block have dimensional attribute values, so that each dimensional attribute has a value that maps to a value in the value set corresponding to the dimension of the block. For example, if the block has two dimensional attributes based on time and device id, each record stored in the block has a time attribute that falls within the time range of the block and a device id from the set of device ids associated with the block. The chunk creation module 450 determines a location for creating a chunk and creates the chunk at the location.
[0067] The database system 110 stores metadata 155 describing the chunk in the metadata storage 140. The metadata for the chunk includes information that associates the chunk with a hypertable. Other types of metadata describing the chunk include the name of the chunk, various value sets for dimension attributes (e.g., time ranges for time attributes, etc.), information describing constraints and indexes for the chunk, etc. The database system 110 may store other metadata associated with the chunk, such as access statistics and data distribution statistics to assist in query planning.
[0068] A hypertable may be associated with certain policy configurations such as indexes, constraints, storage parameters (e.g., fill factor settings, parallel worker settings, auto-clean settings, etc.), foreign key relationships, etc. In an embodiment, each block in a hypertable implements the policy configuration of the hypertable containing the block. Therefore, when a block is created, the block creation module 450 may also create structures such as indexes for the block and update metadata to specify constraints, foreign key relationships, and any other policy configurations for the block. Examples of constraints defined for a block include UNIQUE, NOT NULL, CHECK CONSTRAINT (i.e., timestamps between ranges), FOREIGN KEY, and EXCLUSION constraints. Once a block is created, the block management module 170 continues to manage the block, such as by periodically reindexing old blocks, moving old blocks to slower storage devices over time, adding secondary constraints through dynamic checking, etc.
[0069] In an embodiment, the block management module 170 monitors the size of recently created blocks. Recently created blocks (or recent blocks) refer to blocks created within a threshold time interval of the current time. The size of the threshold time interval may be configurable. The size represents the amount of data stored in the block, such as the byte size of the block, the number of rows of the block, etc. The block management module 170 adjusts the value set of the dimension attribute of the new block being created based on the size of the recently created block. Therefore, if the block management module 170 determines that one or more recently created blocks store data exceeding a certain high threshold, the block management module 170 adjusts the value set of one or more dimensions so that they have fewer elements than the corresponding value set of the recently created block. For example, if the block management module 170 determines that the recently created block has a range of 12 hours for the time attribute, the block management module 170 can reduce the range of the time attribute of the new block being created to 10 hours. Alternatively, if the block management module 170 determines that one or more recently created blocks store data below a certain low threshold, the block management module 170 adjusts the value sets of one or more dimensions so that they have more elements than the corresponding value sets of the recently created blocks below the low size threshold. For example, if the block management module 170 determines that the recently created blocks have a range of 12 hours for the time attribute and store very few records, the block management module 170 may increase the range of the time attribute of the new block being created to 15 hours.
[0070] In an embodiment, the block management module 170 monitors one or more performance metrics of recently created blocks. The block management module 170 adjusts the value set of the dimension attribute of the new block being created based on the performance metric of the recently created block. For example, the block management module 170 can monitor the insertion rate and the query execution time. For example, if the block management module 170 determines that the insertion rate of records for the current size of the block has dropped significantly (e.g., because the database system has begun swapping to disk), the block management module 170 determines that the value set of the dimension attribute of the new block being created makes the new block smaller.
[0071] In an embodiment, the block management module 170 maintains statistics describing the blocks processed by each different query, such as the number of blocks processed by each query. The block management module 170 uses this statistical information to determine the value set of the dimension attributes of the new block being created in order to improve performance. In an embodiment, the block management module 170 monitors the dimension attribute boundaries specified in the query. If the block management module 170 determines that the queries commonly received have a certain boundary pattern, such as a time-aligned pattern (e.g., a typical query requests data for a day between midnight and midnight), the block management module 170 aligns the newly created blocks to match these boundaries. As another example, if the current block has a one-hour time attribute range and the block management module 170 determines that queries typically access data in intervals of the size of a full day, the block management module 170 increases the block size to a size that is more aligned with the access pattern but still maintains a high insertion rate. For example, if 12 hours gives a higher insertion rate than a 24-hour range, the block management module 170 can increase the time attribute range to 12 hours.
[0072] In an embodiment, the block management module 170 determines the value set of the dimension attribute of the block being created based on the range of the dimension attribute specified in the query received by the database system. For example, if the block management module 170 is creating a block with a time attribute range from 11 pm to 11 pm, and the block management module 170 determines that the received query is accessing data from midnight to midnight, the block management module 170 moves the time range of the block being created to match the time range of the query. This improves the performance of the query by avoiding the need to unnecessarily scan two blocks instead of one block.
[0073] In an embodiment, the block management module 170 distributes blocks across multiple locations based on the properties of the storage medium of each location. The block management module 170 identifies the storage medium for storing the new block and accesses the properties of the storage medium, such as the properties describing the access rate of the data stored on the storage medium. The block management module 170 determines the number of blocks that are being allocated to the location from multiple blocks based on the properties of the storage medium corresponding to the location. For example, the block management module 170 accesses a metric describing the rate at which the storage medium accesses random data. Some storage media (e.g., solid-state drives (SSDs) and random access memories (RAMs)) can handle random reads better than spinning hard disk drives (HDDs). Therefore, the block management module 170 allocates more blocks from the multiple blocks to locations with storage media that have faster access times for random access.
[0074] In an embodiment, the block creation module 450 creates new blocks, and "closes" existing blocks - when an existing block approaches or exceeds a certain threshold size (e.g., in bytes on disk or in memory, in number of rows, etc.). Each block is represented by a start time and an end time (defining its interval). However, using a purely size-based approach, the database system does not know a priori the end time of a newly created block. Therefore, when a block is first created, the end time of the block is not set; any row with a time greater than (or equal to) the start time is associated with the block. However, when the size of the block approaches or exceeds a certain threshold, the query planner 425 closes the block by specifying the end time of the block, and the block creation module 450 creates a new block. The new block starts at the time when the old block ended. Using this method, the block has an indeterminate end time of the block until the block is closed. Similar logic applies to indeterminate start times. The initial block can also have both indeterminate start and end times. An embodiment of the database system performs this determination and block creation asynchronously or in the background, while another embodiment performs these actions during the process of inserting (a set of) rows from a received batch into a block. The creation of a new block at insert time can occur in a variety of ways: before inserting rows (query planner 425 determines that an existing block is too full and creates a new block for inserting); after inserting rows into a block; or in the middle of inserting rows (e.g., query planner 425 determines that a block only has room for a subset of rows, so the subset is inserted into the current block and the rest of the set is inserted into the newly created block).
[0075] In other embodiments, the database system limits the block to have a specific time interval (i.e., both the start time and the end time) when the block is created. The system then creates a new block when needed, such as when new data is to be inserted into a time interval that does not yet exist. In one embodiment, the database system also adopts a maximum size even for this method, so that, for example, if the size is approached or exceeded on the first block, a second block is created using the same time interval as the first block, and the query planner 425 writes the new data only to one of the blocks. Once the second block is created, the database system can rebalance the data from the first block to the second block. In another embodiment, instead of overlapping the time intervals of the first and second blocks, the end time of the first block is modified when the second block is created so that they remain disjoint and their time intervals can be strictly sorted. In another embodiment, the database system performs such changes asynchronously so that the oversized block is split into the first and second blocks as a "background" task of the system. In addition, in another embodiment, the second block is created when the insertion occurs at a time value close enough to the end of the time range of the block, rather than only when the dimensional attribute (e.g., time) of the record falls outside the dimension of any existing block. In general, many variations of chunk management for database systems can be performed synchronously at insert time or asynchronously as a background task. Size-based and interval-based chunking are further described below.
[0076] In an embodiment, the block creation module 450 performs conflict detection to ensure that the new block has a set of dimension attributes that do not intersect with existing blocks. For example, assume that the block creation module is creating a block with a time range spanning 24 hours. If the previous block stores data with time attribute values up to midnight (not included) on January 1, the block creation module 450 next creates a block with time attribute values from midnight (inclusive) on January 2 to the next midnight (not included). As another example, if the block creation module 450 is creating a block with a time attribute of 18 hour intervals, if the previously created block covers the time interval from midnight to 3 am, the block creation module 450 next creates a new 18-hour block that spans the time interval from 3 am to 9 pm for the time attribute. The block creation module 450 can create multiple blocks with the same time range but with different value sets for other dimension attributes.
[0077] The block creation module 450 can adjust the block boundaries based on various criteria, some of which may be conflicting. For example, consider a database system having a block for a time interval ending at 3 a.m. and another block from noon to the next midnight. The database system may then receive a request to insert a record with a time attribute value of 4 a.m. Even though the block creation module 450 may be creating a block with a time range spanning 12 hours, in this case, the block creation module 450 may create a new block spanning only a 9-hour time interval from 3 a.m. to noon in order to enforce disjointness. In some embodiments, the block management module 170 determines after the block is created that the range of the block (or the value set of the block) may overlap with other blocks created. In these embodiments, the block management module 170 modifies the existing range of the block to ensure that the range does not intersect with other blocks.
[0078] In some embodiments, across different partitions, the database system can align block start and end times or maintain them independently. In other words, the system can create and / or close all blocks of a hypertable at the same time, or different partitions can be managed differently from each other. In other embodiments, there may be special overflow blocks where data that cannot be placed in some existing blocks is temporarily or permanently placed.
[0079] These graphs (e.g., Figures 1 to 4B ) is intended to be illustrative; other embodiments may include additional or fewer components, some of which may not always be present (e.g., a query parser or cache), or the components may be combined or partitioned in various ways (e.g., a query planner, a query optimizer, and an execution engine). It should be understood that such a representation or partitioning does not change the overall structure and functionality of the database system. For example, it will be appreciated that the methods described herein may be implemented in a system that includes one component that performs both query planning and execution, or in a system that includes a separate component for planning, which then passes the plan to an executor engine for execution.
[0080] Inserting data into a hypertable
[0081] Figure 5 A process of inserting records into a hypertable stored across multiple database system nodes according to an embodiment is shown. The database system 110 receives 510 an insert query (also referred to as an insert request). The insert query identifies a database table, such as a hypertable, a block, or a standard non-partitioned database table and specifies one or more records to be inserted into the database table. The database system 110 may store the records as a hypertable comprising multiple blocks, each of which is stored in a different location.
[0082] After receiving 510 the insert query, the query parser 415 parses the insert query. The query planner 425 processes the query and determines whether the query specifies a supertable, a block, or a standard non-partitioned database table. If the insert query specifies a standard database table or a block, the query planner 425 in conjunction with the execution engine 435 performs the insert on the specified block or standard database table and returns the result.
[0083] If the query specifies a hypertable, the query processor 130 performs the following steps for each record specified in the insert request. The query processor 130 identifies the values of the dimension attributes in the input record. The query processor 130 determines whether the input record should be stored in an existing block or in a new block that needs to be created. In an embodiment, the query processor 130 determines whether one or more dimension values of the input record map to values in a set of dimension attribute values from an existing block storing data of the hypertable; this determination is made to determine whether the record can be stored in the existing block.
[0084] In an embodiment, the query processor 130 provides 520 the dimension attributes as input to a selection function of the block selection module 445, which determines whether the record should be stored in an existing block or whether a new block needs to be created to store the record. If the selection function finds an existing block that matches the record, the selection function outputs information identifying the existing block. If the selection function determines that none of the existing blocks can be used to store the record, the selection function outputs a value (e.g., a negative number) indicating that a new block needs to be created. The block creation module 450 determines 540 whether the record matches an existing block based on the output of the selection function. If the block creation module 450 determines 540 that the record matches an existing block, the block selection module 445 also identifies the location of the existing block, such as whether the existing block is local (i.e., on the current database system node) or remote (i.e., on another database system node). The location can specify the location explicitly or implicitly, including specifying the name of a local database table, the name of a remote database table, the name or network address or remote server, etc. Therefore, the query processor 130 inserts 550 the record into the existing block.
[0085] If the block creation module 450 determines 540 that a new block needs to be created for storing the record based on the output of the selection function, the block creation module 450 determines 560 a configuration of the new block including value sets corresponding to different dimensional attributes of the new block. The block creation module 450 may also identify a location for creating the new block (including identifying a specific storage device or alternatively identifying a specific database system node, wherein the identified node in turn identifies a specific storage device attached thereto). The block creation module 450 creates the new block based on the configuration of the new block and the identified location. The query processor 130 inserts 580 the record into the created new block.
[0086] The block selection module 445 may determine that a record cannot be inserted into an existing block based on various criteria. If a dimensional attribute of the record does not match the configuration of any existing block, then the record cannot be inserted into any existing block. In some implementations, even if the dimensional attribute of the record matches the configuration of an existing block, the block selection module 445 may determine that a record cannot be inserted into a block based on certain policy considerations. For example, the block selection module 445 may determine that an existing block is storing more than a threshold amount of data and that a new record should not be added to the block. Therefore, the block selection module 445 determines that the record cannot be added to an existing block and the database system cannot insert the record into any existing block.
[0087] To create a block locally or insert a record into a locally stored block, i.e., on the current database system node performing the above steps, the database system may perform a function call. To create a block remotely or insert a record into a remotely stored block, i.e., on a database system node different from the current database system node, the database system may perform a remote call, such as a remote procedure call (RPC) or remote SQL query execution. The instructions executed for creating a block or inserting a record into a block may also depend on the location of the block, such as the type of storage medium used to store the block.
[0088] although Figure 5 The steps are described in terms of selecting a function, but other embodiments may use different functions to calculate different values, such as a first function for determining whether a record should be stored in an existing block and a second function for describing a new block if the first function determines that the record cannot be stored in any existing block.
[0089] If multiple blocks reside at the same location, then instead of using separate messages for each insert query, the query processor 130 can send multiple queries in a single message, or it can also send multiple records to be inserted in a single query in a single message. If the blocks involved in the insert query reside on multiple nodes, then in some embodiments the database system node contacts the query or transaction coordinator to obtain additional information that is subsequently used and / or sent when communicating with other database nodes as part of the insert process.
[0090] In some embodiments, the query processor 130 handles errors or lack of timely responses in various ways. If a chunk is replicated between multiple nodes, or the record-to-chunk determination process results in more than one chunk, the query processor 130 issues an insert request to one or more of these chunks, discussed further. Finally, the query planner 425 collects any results or status information from the insert query and returns some results or status information to the requester.
[0091] In some implementations, database system 110 performs several steps to determine the chunk to which a record belongs, many of which involve using metadata. First, query planner 425 determines the set of one or more partitions that belong to the hypertable at the time specified by the record (i.e., the value of the time attribute of the record). If the partition is static, query planner 425 uses metadata about the hypertable itself to determine the partition.
[0092] If the partition changes over time, the query planner 425 uses the time attribute of the record to determine the set of partitions. In one embodiment, the determination involves first using the time attribute value of the row to determine a specific epoch (time interval), and then using the epoch to determine the set of partitions. As described below, the partition can change in the context of system reconfiguration (or elasticity). Secondly, the query planner 425 uses the value of the dimension attribute of the record to determine the partition (from the set of one or more partitions) to which the record belongs. For each of the dimension attributes used for the partition in the hypertable, this step can involve applying some functions to its value to generate a second value. Various functions can be used for this purpose, including hash functions (e.g., Murmur hash, Pearson hash, SHA, MD5, locality-sensitive hashing), identity functions (i.e., simply returning the input), some range-based lookup in a data structure, or some other prefixing or calculation of the input. Third, using the second value (the output of the function), the query planner 425 determines which partition the second value belongs to. For example, this step may involve a range lookup (e.g., finding a partition [x, y] such that the second value is between x and y, including and / or excluding the endpoints), a longest prefix match on the partitions (when the partitions are represented by some binary strings, determine the partition with the largest number of most significant bits that are the same as the most significant bits of the second value), taking the "mod" ("mod") of the second value to the number of nodes to determine the number of matching partitions, or using consistent hashing and other matching algorithms. If the hypertable is partitioned using more than one key, the function can be applied to more than one input (or the function can be applied to multiple inputs separately), resulting in one or more second values (outputs) that will be used to determine the partition to which the record belongs. Finally, each partition for each dimension is associated with a set of blocks (i.e., the time ranges of those blocks storing the partition may be different); the query planner 425 then determines the block from the set based on the time attribute of the record.
[0093] Other embodiments implement the step of determining the block to which the record belongs in an alternative manner. For example, the database system skips the process of first determining the block of the record based on the period of the record, and instead first determines the set of blocks associated with the time of the record. The query planner 425 calculates a function of the partition key of the record to determine a second value, and compares the second value with the partition information associated with each block to select one. These processes can be implemented via various data structures, including hash tables, linked lists, range trees, arrays, trees, tries, etc.
[0094] There are many other optimizations to implement the process by which query planner 425 inserts batches of data into chunks without changing its basic functionality. For example, instead of performing all of these steps for each record, query planner 425 can cache information it determines during its analysis of each record, such as chunks of a hypertable at a given time or time period.
[0095] Other embodiments perform the steps for processing the batch in different ways. For example, after determining the block of the first record, the query planner 425 scans the rest of the batch, finding all other records associated with the same block (if any). The query planner 425 then inserts these records into the selected block and deletes them from the batch. The query planner 425 then repeats the process: selects a record in the (now smaller) batch, scans the rest of the batch to find records with similar block associations, sends this set of one or more records to a second block, and then repeats the process until the batch is empty.
[0096] The insertion process above describes records as being associated with a single block. Alternatively, records may be mapped to multiple blocks. For example, as described herein, the chunking process may create more than one block during a particular interval (e.g., if the size of the inserted data exceeds a certain threshold), in which case the selection function selects a block, e.g., randomly, cyclically, or based on their size. As another example, the database chooses to insert records into multiple blocks to replicate the data for reliability or high availability. Such replication may be performed by the query planner 425 as part of the same steps described above, or the query planner 425 first inserts each of the records into a primary block, and then the database system 110 copies the inserted records to replicas of the block.
[0097] In an embodiment, the database system 110 replicates blocks such that different blocks of the same hypertable can be stored with different numbers of replicas. Additionally, the database system can determine the number of replicas of a block based on the age of the block. For example, more recent blocks can be replicated more times compared to older blocks. Additionally, older blocks with an age greater than a threshold can be not replicated. The database system 110 can determine the age of a block based on the value of the time attribute of the block. For example, if the time range [t1, t2] is older than the time range [t3, t4], e.g., t2 < t3, then it can be determined that the block storing records with a time attribute within the range [t1, t2] is older than the block storing records with a time attribute within the range [t3, t4]. Alternatively, the age of a block can be determined based on the creation time of the block. For example, a block created a week ago has an age value greater than a block created today.
[0098] In an embodiment, the database system copies different blocks to locations with different characteristics. The database system selects a location with specific characteristics based on the configuration of the block. For example, the database system stores and / or replicates the most recent blocks (which have been inserted or selected regularly) on a fast storage medium (e.g., SSD), while the database system stores and / or replicates older blocks on a slower storage medium (e.g., HDD).
[0099] In an embodiment, the database system reuses the replication techniques applied to the base tables of the database, i.e., physical replication of the entire database and cold / hot backups, logical replication of individual tables, and backups. The database system also uses the write-ahead log (WAL) of the database for consistent checkpointing. In other words, even if a replication or backup policy (or command) is defined on a hypertable, the system can perform these actions by replicating or checkpointing the constituent blocks of the hypertable. In another embodiment, replication and high availability are directly implemented by the database system by copying writes to multiple block replicas (e.g., via a two-phase commit protocol) rather than by using the database's underlying log-based techniques.
[0100] In an embodiment, the database system enables different policies to be defined based on block boundaries, e.g., a higher replication level for more recent blocks, or a lower replication level for older blocks, in order to save disk space.
[0101] In an embodiment, the database system also moves blocks between locations as they get older (e.g., from being stored on a faster SSD to being stored on a slower HDD, or from a faster or larger server to a slower or smaller server). The database system associates each hypertable with a threshold age value. The database system also associates locations with types. For example, different types of locations may have different access times, different storage capacities, different costs, etc. If the database system identifies a block of a hypertable with an age value greater than the threshold age value of the hypertable, the database system moves the identified block from a location of a particular type to another location of a different type. Thus, the database system may store different blocks of the same hypertable in locations of different types. In addition, the database system automatically changes the mapping of blocks of a hypertable to locations over time as newer blocks are received and existing blocks become older. In another embodiment, the move occurs only upon request by a command (e.g., from an external process or database user) that specifies the age associated with the hypertable and the location to move any selected blocks between.
[0102] Handling queries that read data
[0103] Figure 6 6 is a flow diagram of a process for executing a query for processing records stored in a hypertable, according to an embodiment. The database system receives 610 a query for reading data (e.g., via a SELECT statement in SQL). Upon receiving the query, the query parser 415 parses the query (optionally using a cache of parsed queries). The query planner 425 processes the query and determines whether any table specified in the query corresponds to a hypertable, a block, or a standard non-partitioned database table. The database system performs the following steps in these different scenarios, each of which results in some results being returned to the requester (or some form of error if any problems occur).
[0104] For each hypertable specified in the first query, the query planner performs the following steps in conjunction with the execution engine 435. First, the query planner 425 analyzes the query to determine 620 a set of blocks that can contribute results to the answer to the query. This analysis typically involves metadata about the blocks maintained by the database system 110 and constraints specified by the predicate of the query. For example, these constraints can be based on the value of a particular field (e.g., the selected row must have a device identifier equal to 100 or 450), or these constraints can include some type of time range (e.g., the selected row must specify that its time value is within the past hour, or between July 2016 and August 2016). Among other things, the metadata stored about each block can specify the time range and any other partitioning keys associated with the particular block. For example, a block may be storing the last day of data for device identifiers between 0 and 200. These examples are illustrative only and various techniques that the system can employ are described herein. The query planner 425 uses the metadata to determine the appropriate block, for example, a device identifier of 100 will be associated with a block storing device identifiers between 0 and 200.
[0105] The following steps 630, 640, 650 and 660 are repeated for each block determined. The query planner 425 uses metadata to determine the location where these blocks are stored - for example, a storage device such as a local or network attached disk, or other database system node. These blocks can be stored in a local or remote location of the query planner 435. The query planner 425 determines 640 whether the block is stored locally or stored on a remote server. If the query planner 425 determines that the block is stored in a local location, the query planner 425 queries the local block (for example, via a direct function call), otherwise the query planner 425 sends 660 queries to the remote location where the block is stored (for example, by issuing a SQL query via an external data wrapper, by sending a remote procedure call (RPC), etc.). In addition, the query planner 425 can change the query execution or plan according to the nature of the location where they are stored (for example, the type of disk or node). When multiple blocks share the same location, query planner 425 may generate a single query for the set of blocks for the location or generate separate queries for each block, and these separate queries may be sent to the location in a single message or as separate messages for each query.
[0106] The query planner 425 issues queries to these locations and waits for their results. If some locations do not respond or return an error after a period of time, the query planner 425 can take several different options, including retrying the query to the same location, retrying the query to a different location of a replicated block, waiting indefinitely, returning partial results to the client, or returning an error. The query planner 425 receives 670 or collects the results of these queries and merges the results. Depending on the query, results, metadata, and additional information, the query planner 425 may optionally determine that it needs to query additional blocks to resolve the first query (e.g., when "looking back in time" from a recent time interval to an older interval in order to find some values that match a particular predicate).
[0107] Depending on the query, the query planner 425 may perform 680 post-processing of the results. Such post-processing includes unioning the returned results, performing aggregations such as SUM or COUNT on the results, sorting the merged results by a particular field, applying a LIMIT that causes the system to return only a certain number of results, etc. It may also involve more complex operations when merging the results of the blocks, for example, when the top k calculated results are calculated across partial results from each block. Finally, the system returns the results of the first query. The results of the query may include one or more tuples or an error code if the processing of the query resulted in an error.
[0108] In some embodiments, queries across multiple database nodes may also involve the use of a query or transaction coordinator so that contact coordination is obtained to obtain additional information that is subsequently used and / or sent when communicating with other database nodes as part of the query process.
[0109] The node may also receive queries for one or more blocks, for example because the node is a recipient of a query generated by processing a first query of a hypertable. For each block specified in the query, the query planner 425 performs the following steps. The query planner 425 plans and executes queries on local blocks. This uses query planning techniques including selecting and optimizing the use of indexes, performing heap scans, etc. The query planner 425 receives the results of the query. Third, depending on the query, the query planner 425 may also post-process the results (as described above, for example, sorting the data, performing aggregations, applying restrictions, etc.). The query planner 425 then returns the results of the query.
[0110] A database system node may receive queries for traditional database tables, which involves processing the query in a standard manner: planning and executing the query on the specified tables, receiving the results, optionally post-processing the results, and returning the results.
[0111] The query may also specify multiple tables or joins between tables. The processing of the database system depends on the type of table specified (e.g., super table, block, standard non-partitioned table) and is related to the above steps, but individual steps may be different or additional steps may be required based on the actual query.
[0112] Alternative implementation of query processing based on hypertable
[0113] Ideally, database users should be able to interact with time series data as if it were in a simple continuous database table. However, using a single table does not scale for the reasons discussed above. However, requiring users to manually partition their data presents a number of complexities, for example, forcing users to constantly specify which partition to query, how to compute joins between them, or how to properly size these tables as workloads change.
[0114] To avoid this management complexity while still scaling and supporting efficient queries, the database system hides automatic data partitioning and query optimization behind its hypertable abstraction. Hypertables and their corresponding schemas are created using simple SQL command execution, and are accessed using standard SQL commands as if they were a single table. Furthermore, the schema can be changed through standard SQL commands, just like a normal database table; transparently to the user, the database system automatically modifies the schema of all the underlying blocks that make up the hypertable.
[0115] In an embodiment, the database system provides this functionality by hooking into the query planner of a relational database such as PostgreSQL, so that the database system receives a native SQL parse tree. The database system uses the tree to determine which server and hypertable block (native database table) to access, how to perform distributed and parallel optimizations, etc.
[0116] Many of these same optimizations apply even to single-node deployments, where the hypertable is automatically split into chunks, and the associated query optimizations still provide many performance benefits. This is especially true if the chunks are distributed across various locations on the node (e.g., across multiple local or network attached disks). In an embodiment, the placement of chunks on database nodes is specified by commands or policies given by a database administrator or user.
[0117] In an embodiment, the database system partitions its hypertable only in a single dimension—by time—rather than two or more dimensions (e.g., time and space dimensions). For example, partitioning based on a single time dimension can be used to deploy a database system on a single node rather than a node cluster.
[0118] In addition, hypertables may be defined recursively. Specifically, a block of a hypertable may be further partitioned (by the same or different partitioning keys, and using the same or different time intervals) and thus behave like another hypertable.
[0119] Chunks are created and sized dynamically at runtime to optimize performance in both cluster and single-node environments. Partitioning the hypertable along additional dimension attributes (besides time) parallelizes inserts to the nearest time interval. Similarly, query patterns often span time or space slices, thus also resulting in performance improvements through the chunking arrangements disclosed herein.
[0120] The arrangement of these blocks can also vary based on deployment, workload, or query requirements. For example, blocks can be randomly or purposefully spread across locations to provide load balancing. Alternatively, blocks that belong to the same region of the key space of the partition field (e.g., a range of values or hash values, or a set of continuous values of a key) but vary by time intervals can be collocated on the same server. This avoids the query from contacting all servers when executing a query for a single object in the space (e.g., a specific device), which can help reduce tail latency under higher query loads and achieve efficient connections.
[0121] The database system determines where the chunks should be placed when they are created; this determination is based on various one or more metrics, including random or performed through a round-robin distribution strategy, based on server load (e.g., request rate, CPU utilization, etc.), based on existing usage (e.g., size of existing chunks in bytes or rows), based on capacity (e.g., total memory or storage capacity, free memory, available storage, number of disks, etc.), based on configured policies or specified by an administrator, etc. The database system or administrator may also choose to relocate (move) or copy chunks between servers.
[0122] Even in a single-node setting, chunking still improves performance over vanilla use of a single database table for both read and write queries. Correctly sized chunks ensure that most or all of a table's indexes (e.g., B-trees) can reside in memory during inserts to avoid thrashing when modifying any position in these indexes. In addition, by avoiding overly large chunks, the database system avoids expensive "clean-up" operations when removing data, because the system can perform such operations by simply discarding chunks (internal tables and / or files) rather than deleting individual rows. For example, the removal may be the result of data deletion (e.g., based on automatic data retention policies and processes), or may be the result of a failed or interrupted large batch of inserts (non-committed rows need to be removed subsequently). At the same time, avoiding overly small chunks can improve query performance by not needing to read additional tables and indexes from disk, or not needing to execute query plans on a large number of chunks.
[0123] The database system considers several factors for determining the block size. First, the database system maintains metadata specifying the number of partitions that the additional partition field divides a specific time interval into. For example, 10 machines each with 2 disks may use 20 partitions (or multiple partitions per server and / or disk). This means that the key space of a specific field (e.g., device ID, IP address, or location name) is divided into 20 ranges or sets. Then, the database system determines which range (or partition) a specific value is associated with by performing a search or comparison process. In one embodiment, the field is a string or binary value, and the database system divides the key space by the prefix of the value of the field, and then maps the value to one of these partitions based on the partition that shares the longest common prefix. Alternatively, the database system uses some form of hashing so that the space of the hash output is divided into a specific number of ranges or sets (e.g., continuous ranges, sets defined by dividing the entire hash output space, sets defined by taking the "mod" of the hash output space to the number of nodes, sets defined by consistent hashing, etc.). The database system applies a hash function to the input value to produce an output value; the database system determines a range or set that includes the output value, which then corresponds to the partition to which the input value belongs. The database system can use a variety of functions in such cases, including hash functions (e.g., Murmur hash, Pearson hash, SHA, MD5, locality-sensitive hashing), identity functions (i.e., simply returning the input), or some other prefixing or calculation of the input.
[0124] Second, once the number of partitions based on the partition key is determined—and in practice, this number can change over time due to elasticity, discussed below—then the duration of the chunk also determines its size. For a constant input rate and some given number of partitions, chunks with intervals measured in hours are typically much smaller than chunks with intervals measured in days.
[0125] In one embodiment, the database system makes the time intervals static or manually configurable. Such an approach is appropriate if the volume of data in the system is relatively stable (and known), and it provides the database administrator or user with control over the operation of the database system. However, such fixed time intervals may not work well when the volume of data varies - for example, a time interval suitable for a service that extracts data from 100 devices is not appropriate when the system is expanded to 100,000 devices - or require the administrator or user to change the interval size over time (to apply to future intervals or to split existing intervals into multiple chunks).
[0126] In one embodiment, the database system dynamically determines the time interval of the chunks based on the chunk size rather than based on a fixed time interval. Specifically, during insert time, the database system determines whether the chunk is approaching or has exceeded a certain threshold size, at which point the database system "closes" the current chunk and creates a new chunk (e.g., by using the current time as the end time of the current chunk and as the start time of the new chunk).
[0127] The threshold size is given as a default value in the software configuration, which can be configured by the database system administrator, and the size can be changed during runtime by the administrator or the logic of the database system (so that blocks in the same database system can have different threshold sizes). In an embodiment, the database system selects the size based on the resources of the system, for example, based on the memory capacity of the server, which can also take into account the table mode to determine the amount of indexes that will be needed and their size requirements. This adjustment takes into account the realized or potential changes in the mode over time. For example, if indexes are added to many fields (columns), the amount of memory required to store these fields changes, which causes the database system to use smaller blocks; if many fields are not indexed, the database system can consider these fields differently from the mode without any unindexed fields (because indexes can be added to these fields later to achieve more efficient queries). Alternatively, recognizing that the database will eventually store the table in a file with a maximum size (e.g., 1 GB) in the underlying file system, the system ensures that the block size is less than the maximum size. In an embodiment, the size is selected as a measurement or estimation of the read / write performance on the block size.
[0128] In some implementations, the database system creates new blocks even if the current block size is less than a certain threshold (i.e., the current block size is "close" to the threshold, and has not yet exceeded or equaled the threshold), to leave some "free space" for the possibility that the database system must backfill out-of-time data into older blocks. When writing to older or "closed" blocks, different implementations of the database system allow blocks to become arbitrary, create new overlapping blocks only for newly written excess data, or split existing blocks into two, among other methods. If overlapping blocks are created, the database system follows its policy for writing and reading overlapping blocks.
[0129] In another embodiment, the database system dynamically determines the time interval of the chunks based on historical intervals and their sizes. In this case, a new chunk is created with an end time, but the end time is automatically set by the database system based on the resulting size of an earlier chunk with a particular interval duration. For example, if the database system (or a user or administrator) desires chunks that are close to 1 Gb in size, and a previous 12 hour chunk resulted in a chunk that was 1.5 GB in size, the database might create subsequent chunks that are 6 hours in size. The database system may continue to adjust the spacing of chunks during its operation, for example, to account for varying amounts of data per interval, to account for different target sizes, etc.
[0130] In some embodiments, the database determines chunks based on a mix of time intervals and threshold sizes. For example, the database system (or administrator) specifies that chunks have a predetermined time interval—so that the start and end times of the chunks are specified at the creation time, as described above—and also specifies that the chunks also have a maximum size if the insertion rate for that interval exceeds a certain amount. This approach avoids the problem of chunking based purely on fixed time intervals in scenarios where the system load for each interval varies over time. If the size of a chunk approaches or exceeds its maximum allowed threshold during the middle of the current time interval, the database system creates a new chunk that overlaps the same interval, or the database system switches to using a different time interval. For the former, the two chunks represent the same interval, so inserts can choose to write to one of them (while read queries are both of them). For the latter, the database system can change the time interval of the chunk to a smaller time interval and create a new non-overlapping chunk to make it successful in time. As described earlier, such chunk management can be performed synchronously or asynchronously, for example, a background task splits an overly large chunk into two chunks.
[0131] Chunking can also limit the predetermined time intervals to regular boundaries (e.g., 1 hour, 6 hours, 12 hours, 24 hours, 7 days, 14 days) rather than arbitrary boundaries (e.g., 11 minutes, 57 minutes). This embodiment allows the chunk intervals to be well aligned with the time periods over which data can be queried or deleted, for example, according to a data retention policy such as "delete data older than 12 hours in length." In this way, the database system implements such a policy by deleting an entire chunk once its records are all at least 12 hours in length, rather than partially deleting individual rows within the chunk: it is more efficient to discard an entire chunk (database table) than to delete an equivalent number of rows in the table.
[0132] The database system selects these boundaries in a way that they are well-composed, e.g., the boundaries are multiples of each other or aligned in some other way. Switching between the various granularity sizes is performed automatically by the database runtime (e.g., in response to changing data rates) or by configuration by a user or administrator. Similarly, an administrator can signal the database system through configuration commands to create new chunks or chunk intervals, rather than always closing chunks and creating new chunks based on an automatic policy.
[0133] In one embodiment, the database system also applies such adaptability of the configuration of the block to non-time dimension attributes used to define the scope of the block. For example, if the partitioning of the hypertable is also performed on a field representing the device id, the database system can increase the number of partitions (value sets) defined on this field from 10 to 20. Such changes, which can be performed automatically by the database system or through configuration by a user or administrator, can be used to improve hypertable performance. For example, if queries typically specify a single device id according to which data is selected (SELECT), the latency of the query can be improved if the block containing the specified device includes information about fewer other devices - which can be achieved by increasing the number of partitions on the device id field.
[0134] In another embodiment, the database system may employ different time intervals across different partitions. For example, if the hypertable is also partitioned on a field representing a customer id (e.g., each different customer id is a separate partition), the database system may independently maintain different time intervals for different customer ids (when partitioning on the time attribute). Such an approach may be beneficial if different customers have very different insert and select query patterns and different data retention requirements.
[0135] In general, database systems employ a variety of approaches to chunk management, assuming that there are several different goals and engineering tradeoffs between approaches. These goals include optimizing size, aligning the time intervals used to drop chunks while preserving data integrity, minimizing locking or other performance penalties due to volatility, avoiding arbitrary-sized intervals, creating chunk boundaries that are most conducive to constraint exclusion, increasing system parallelism, improving query performance, and simplifying code, operational, and management complexity. Different deployments of database systems may choose to use different approaches depending on their setup and needs.
[0136] Adjusting partitioning strategies in light of system reconfiguration
[0137] The amount of data stored in the database system 100 increases over time. For example, a large amount of time series data may be received by the database system 110 and stored in a database table. The database system 110 often reconfigures the system to increase storage capacity, such as by adding storage devices. Conventional systems adapt to changes in system configuration by moving data. For example, a system may be reconfigured due to the addition of a new server, and some data blocks may be moved from existing servers to the new servers to ensure that the new servers bring additional capacity to the system. Therefore, a large amount of data is moved, making system reconfiguration an expensive and time-consuming process. This new configuration of participating servers is also referred to as a "view" representing a collection of servers and the configuration of the servers, such as the capacity of the servers or the number of disks. The ability of the system to adapt to changes in computing resources so that all available resources can be used effectively is called elasticity.
[0138] An embodiment of the database system 110 adapts to the reconfiguration of the system without performing such data movement. Specifically, the database system 110 provides elasticity by creating a new set of blocks and partitioning when the database system is reconfigured to increase storage capacity. The database system can use different partitioning strategies for the new set of blocks created after the system is reconfigured. For example, if the previous partitioning strategy created 20 partitions for 10 servers, the new partitioning strategy may create 30 partitions to take into account the 5 new servers added to the database system. In another example, the previous partitioning strategy may create 20 partitions to arrange 5 partitions on each of 4 servers, but when adding an additional 1 server, the new partitioning strategy may then arrange 4 partitions on each of the 5 servers. In some embodiments, the database system distributes the created multiple blocks so that more blocks from multiple blocks are allocated to the new server compared to the existing servers. This allows for better load balancing across servers. In another embodiment, the new server is allocated larger blocks than the blocks allocated to the existing servers. Larger blocks have a configuration that enables them to store more data than smaller blocks. Data can still be read or written to previously created chunks or newly created chunks. Since writes to time series datasets are typically for the most recent time interval, and many query workloads also process recent data, the load of new collections across servers is still balanced even if existing data is not moved.
[0139] 7 (A-B) illustrates data partitioning of a database table for accommodating the addition of locations to a database system according to an embodiment of the present invention.
[0140] As shown in FIG. 7(A), the database system 110 may have multiple storage locations 710a, 710b, 710c, and 710d. FIG. 7(A) shows the data distribution of a database table having attributes including temporal attributes and spatial attributes (recalling the use of the term "spatial" partition to represent any partition on a non-temporal attribute). In response to a request to insert a record in the database table, the database system 110 distributes the data of the database table according to a partitioning strategy that assigns a block 210 to a location 710. In the example configuration shown in FIG. 7(A), the database system 110 creates multiple blocks including 210a, 210b, 210c, and 210d, and assigns one block to each location. The blocks are distributed across the locations of the database system 110 along the temporal attributes and the spatial attributes. Therefore, each block is associated with a temporal range and a spatial range and stores records having temporal attributes and spatial attributes that are within the temporal range and spatial range of the block. In the example configuration shown in FIG7(A), each of blocks 210a, 210b, 210c, and 210d is associated with the same temporal attribute range, i.e., [0, 6], but has a different spatial attribute range. For example, block 210a has a spatial range of [A, F], block 210b has a spatial range of [G, L], block 210c has a spatial range of [M, S], and block 210d has a spatial range of [T, Z].
[0141] FIG. 7(B) shows the partitioning of the blocks of the database table after a period of time has passed such that the database system has received a request to insert a record with a time attribute later than 6. For example, in response to receiving a request to insert a record with a time attribute of 7, the database system creates a new plurality of blocks 210e, 210f, 210g, and 210h. The new plurality of blocks are distributed across locations according to the same partitioning strategy as described above. According to the partitioning strategy, each block from the new plurality of blocks is associated with a new time range [7, 15]. In this illustration, blocks stored in the same location have the same spatial range. For example, blocks 210a and 210e assigned to location 710a both have a spatial range [A, F], blocks 210b and 210f assigned to location 710b both have a spatial range [G, L], and so on. The database system can also assign blocks with different time intervals but the same spatial range to different locations.
[0142] FIG. 7(C) illustrates the partitioning of the blocks of the database table after a new location 710e is added to the database system 110. Thus, the database system 110 has a plurality of locations including locations 710a, 710b, 710c, 710d, and 710e. Although FIG. 7(C) illustrates the addition of a single location to the database system, more than one location may be added to increase the storage capacity of the database system 110. In response to adding the new location, the database system 110 uses a new partitioning strategy to distribute records across the locations. Thus, in response to receiving a subsequent insert request, for example, with a value of a dimension attribute that is not mapped to any existing block, the database system 110 creates a plurality of blocks including 210i, 210j, 210k, 210l, 210m, and 210n. Blocks 210i, 210j, 210k, 210l are mapped to locations 710a, 710b, 710c, 710d, and blocks 210m and 210n are both mapped to new location 710e. In other embodiments, the database system may allocate more or fewer blocks to the new location that is added. Therefore, subsequent records received are distributed according to the new partitioning strategy. In the embodiment shown in FIG. 7(C), the database system 110 does not move any data stored in the blocks created before the new location is added. However, the blocks created in response to the addition of the new location are distributed according to the new partitioning strategy that balances data storage across all available locations. In the example shown in FIG. 7(C), more blocks are allocated to the new location because the storage and computing resources of the new location may not be fully utilized compared to the existing location where data has been previously stored. However, over time, as additional data is stored in the new location, the utilization gap between the new location and the existing location decreases without having to move any data from the existing location to the new location.
[0143] As shown in Figure 7(C), the new partitioning strategy creates multiple blocks with more blocks after adding the new location. Therefore, each spatial extent in the new partitioning strategy is smaller than the spatial extent of the partitioning strategy used before adding the new location.
[0144] In another embodiment, the database system allocates a larger portion of the new data to the new locations by allocating blocks with dimensional ranges with larger sets of values, rather than allocating a greater number of blocks to these locations as shown in FIG. 7(C). For example, the database system can create a single block with a spatial range of [Q, Z] assigned to location 710e instead of block 210m with a spatial range of [Q, U] and block 210n with a spatial range of [V, Z].
[0145] In some implementations, when database system 110 detects that a new location is being added to the database system, database system 110 dynamically changes the partitioning based on the new storage configuration. In other implementations, the partitioning strategy is configured by a user, such as a database system administrator.
[0146] The partitioning strategy determines how new chunks are created and assigned to locations for storing them. For example, if a partitioning strategy is being implemented and a new chunk needs to be created (e.g., to insert a record that cannot be inserted into an existing chunk), multiple chunks may be created and distributed according to the partitioning strategy. The partitioning strategy may specify various aspects of the creation of new chunks, including the number of chunks being created, the configuration of each chunk being created (the configuration includes the value sets for different dimensional attributes of each chunk), and the mapping of chunks to locations.
[0147] The partitioning strategy may store information specifying various aspects of block creation / distribution as metadata, for example, a mapping from blocks to locations may be stored using a mapping table that explicitly stores the location of each block being created. Alternatively, the partitioning strategy may specify various aspects of block creation / distribution using instructions, for example, the partitioning strategy may specify a mapping from blocks to locations using a function (or instruction set) that determines the location of a block given a block configuration and potentially other system information as input. Different partitioning strategies may specify different mapping functions (or instruction sets). Alternatively, different partitioning strategies may use the same mapping function (or instruction set) but pass different parameter values as input. Such mapping functions (or instruction sets) may include random selection, round-robin selection, hash-based selection, selection based on the number, size or age of blocks being stored, selection based on the age of when a location was added to the database system, load balancing strategies based on server resources (including insertion rate or query rate, CPU capacity, CPU utilization, memory capacity, available memory, etc.), load balancing strategies based on disk resources (including total disk capacity, unused disk space disk, disk IOPS capacity, disk IOPS usage, etc.), and other standard or algorithmic methods and some combination thereof. The partitioning strategy may use a combination of the above techniques.
[0148] In an embodiment, the partitioning strategy specifies the size of the plurality of blocks being created. The size of the plurality of blocks may represent the number of blocks in the plurality of blocks being created. Alternatively, the size of the plurality of blocks may represent the aggregate size of the blocks in the plurality of blocks being created, wherein the size of each block represents a measure of the amount of data that may potentially be stored in the block. The size of the block is determined based on the configuration of the block including the value sets of different dimensional attributes of the records stored in the block. For example, the database system may create larger or smaller blocks by specifying larger / smaller ranges (or value sets) for the dimensional attributes, respectively.
[0149] In some embodiments, the database system 110 moves existing data in certain scenarios. For example, the database system can implement a strategy that aligns blocks with specific time intervals. Therefore, creating a new block at a time based on the time when the new location is added may cause a violation of such a strategy. For example, the database system can implement a standard that the block has a 12-hour time range. However, if adding a new location to the database system occurs at 3 hours within a 12-hour time interval, the database system will not be able to incorporate the new location for another 9 hours, or must maintain some blocks with a 3-hour interval. Therefore, in certain scenarios, for example, if the amount of data stored in each block currently being filled is lower than a threshold amount, the database system moves or reallocates existing blocks instead of creating new blocks in response to adding a new location. Therefore, the database system moves the data of the set of blocks currently being filled with records across a new set of blocks distributed on a new plurality of locations and continues to add records to the new set of blocks.
[0150] In another embodiment, the database system delays implementing the new partitioning strategy based on the new location added until the time and block alignment are well matched. This delayed action can be used when removing servers in a planned manner, adding new servers, or even when a server crashes (if the system has replicated blocks between multiple servers for high availability). For example, if the system already has blocks with a time range extending until midnight, and the reconfiguration time is 11 pm, the database system may not create blocks based on the new partitioning strategy for 1 hour (e.g., until a record with a time attribute after midnight is inserted), but the reconfiguration will take effect when a new set of blocks is created. In such a scenario, existing blocks are not reconfigured and new blocks are only allocated on the new set of servers. However, the time range of the blocks is the same before and after the new location is added.
[0151] Figure 8A flow chart showing a process of modifying a data partitioning strategy of a database system in response to adding a new location to the database system according to an embodiment is shown. The database system 110 includes a plurality of locations referred to as a first plurality of locations. The database system 110 receives 810 a request to insert a record in a hypertable. The database system distributes the blocks according to the first partitioning strategy P1. Therefore, the database system 110 creates 820 multiple blocks and distributes the multiple blocks across the first plurality of locations. For example, if the database system has 5 locations, the database system 110 can create 20 blocks and store 4 blocks in each location. The database system 110 distributes the blocks based on the dimensional attributes of the record including at least the time attribute. The partitioning strategy specifies various aspects of the block / creation and distribution, including: the number of blocks that can be created, the configuration of the blocks, and the mapping of the blocks to the locations. The database system can repeat steps 810 and 820 multiple times, for example, until the database system 110 is reconfigured to change the number of locations.
[0152] The database system 110 receives an indication to add one or more new locations. For example, the new location may be a storage device of an existing server added to the database system by a system administrator. Alternatively, the new location may be a new server including one or more storage devices added to the database system for storing and processing data. As another example, the location may be a storage device of a remote system that allows the database system 110 to store data thereon, such as a cloud-based storage device. The indication received by the database system to add one or more new locations may identify a specific storage device added to the database system or may identify a server added to the database system.
[0153] In an embodiment, the database system 110 receives an indication to add a location by performing a check of all peripheral devices and servers reachable through one or more database system nodes 310. In other embodiments, the database system 110 receives an indication by a command executed by a database user or administrator, by receiving a message from a new location. Adding a location to the database system causes the database system 110 to have a second plurality of locations that is greater than the number of locations in the first plurality of locations. The indication to add one or more locations is associated with a reconfiguration time, for example, the time the indication is received or the time the addition of the one or more new locations is completed.
[0154] After receiving an indication to add one or more new locations, the database system receives an insert request. For example, if the record in the received insert request cannot be inserted into an existing block, the database system 110 creates 840 a second plurality of blocks. The database system 110 creates a second plurality of blocks based on a second partitioning strategy P2 and assigns them to the locations. For example, as shown in FIG. 7(C), the second partitioning strategy P2 maps a second plurality of blocks to a second plurality of locations. The blocks may be evenly distributed across the second plurality of locations. Alternatively, the number of blocks or partition ranges assigned to the new location may be greater than the number of blocks or partition ranges assigned to the existing location. For example, more blocks from the second plurality of blocks may be assigned to the new location compared to the existing location. Alternatively, blocks configured to store more data may be assigned to the new location compared to the existing location. Block C1 may be configured to store more data than block C2 by specifying a value set of a dimension attribute having more elements for block C1 compared to a value set of the same dimension attribute of block C2. For example, the time attribute of block C1 may be specified to have a larger time range than the time attribute of block C2.
[0155] The database system 110 then receives 850 a request to insert data into a database table. The database system 110 stores 860 the received records into blocks based on the dimensional attributes of the records. Figures 9 to 12 As further described, the record may be inserted into a block created based on the first partitioning strategy or the second partitioning strategy.The database system 110 identifies a reconfiguration time T associated with adding a new location to the database system.
[0156] In an embodiment, the database system inserts records into chunks based on the time attribute of the records. Thus, even if a new partitioning strategy is defined, the database system may receive insert requests and create chunks based on the previous partitioning strategy. For example, the database system may receive some records very late (i.e., the time at which these records are received may be significantly after the value of the time attribute of the record), for example, due to delays caused by the network or other resources. The database system may create chunks for storing these records based on the old partitioning strategy. Thus, the database system may implement multiple partitioning strategies simultaneously - depending on the data of the records received and needed to be inserted into the hypertable.
[0157] Fig. 9 The partitioning strategy for creating a block based on the time attribute of the record according to an embodiment is shown. Therefore, regardless of the time when the insert request is received, if an insert request is received for a record with a time attribute value before the reconfiguration time T, any new block created for storing the record is created based on the first partitioning strategy. Fig. 9A timeline 900 and various events along the timeline are shown. For example, the database system initially has three locations (disks) 910a, 910b, and 910c, and chunks are created according to partitioning strategy P1. At reconfiguration time T, a new location 910d is added to the database system 110. However, if an insert request received after the reconfiguration time T has a time attribute value before the reconfiguration time T, the database system creates a chunk for storing records according to the first partitioning strategy P1 (if none of the existing chunks can store the record). Furthermore, if an insert request received after the reconfiguration time T has a time attribute value after the reconfiguration time T, the database system creates a chunk for storing records according to the second partitioning strategy P2 (if none of the existing chunks can store the record). Therefore, the time interval T1 for creating chunks according to the first partitioning strategy P1 may extend beyond the reconfiguration time T. The time interval T2 indicates the time when chunks are created according to the second partitioning strategy P2.
[0158] Fig.10 A flowchart of a process for selecting a partitioning strategy for creating a block based on a time attribute of a record according to an embodiment is shown. If the database system determines for a record being inserted that the record cannot be stored in any existing block and a new block needs to be created, the database system calls Fig.10 The process shown. The database system 110 determines 1010 a value of a time attribute of a record received for insertion into a database table. The database system 110 compares 1020 the value of the time attribute of the record with a reconfiguration time T. If the database system 110 determines that the time attribute of the record is less than the reconfiguration time T, the database system 110 creates 1030 a block based on a first partitioning strategy P1. If the database system 110 determines that the time attribute of the record is greater than (or equal to) the reconfiguration time T, the database system 110 creates 1040 a block based on a second partitioning strategy P2. The record is stored 1050 in the created block.
[0159] Fig.11 Shown is a partitioning strategy for selecting a chunk to create based on the time at which a record is received by a database system according to an embodiment. Fig.11A timeline 1100 and various events along the timeline are shown. For example, the database system initially has three locations (disks) 1110a, 1110b, and 1110c, and chunks are created according to partitioning strategy P1. At reconfiguration time T, a new location 1110d is added to the database system 110. The database system selects a partitioning strategy for creating chunks based on the arrival time of the insert request (assuming that no existing chunks can be used to store the records received for insertion into the hypertable). Therefore, after the reconfiguration time T (i.e., during the time interval T2), chunks are created according to the second partitioning strategy P2, while before the reconfiguration time T (i.e., during the time interval T1), chunks are created according to the first partitioning strategy P1. Therefore, the partitioning strategy selected for creating chunks is selected independently of the value of the time attribute of the record being inserted. For example, if for any reason a record with a time attribute value corresponding to a time occurring before the reconfiguration time T arrives late, i.e., after the reconfiguration time T, the database system creates a chunk for storing the record according to the second partitioning strategy P2. Therefore, records having a time attribute value less than the reconfiguration time T may be stored in a block created according to partitioning strategy P1 or P2.
[0160] In some embodiments, even if an insert request arrives after the reconfiguration time T, the database system continues to insert records into the block created before the reconfiguration time T as long as the time attribute of the record corresponds to the time range of the block. In other embodiments, the database system modifies an existing block created according to the first partitioning strategy P1 so as to reduce the time range (if necessary) to correspond to the latest record inserted into the block. For example, if the arrival time of the insert request is 5:30 am and the current time range of the block is until noon, the database system identifies the record with the highest value of its time attribute in the block. Assuming that the record with the highest time value in the block has a time of 5:45 am, the database system modifies the end of the time range of the block to a time greater than or equal to 5:45 am, for example, 6 am. Subsequently, if the database system receives a record at a time greater than 6 am, the database system creates a new block according to the new partitioning strategy P2 starting at 6 am.
[0161] In some embodiments, as a result of the reconfiguration of the system, the database system may create overlapping blocks. The database system implements the following policy: After the reconfiguration of the system, the database system does not insert records into blocks created based on the first partitioning strategy P1. Therefore, after the reconfiguration of the system, even if there are existing blocks created based on strategy P1 that are mapped to the dimensional attributes of the records, the database system creates new blocks for storing records based on partitioning strategy P2. Therefore, records with specific dimensional attributes may potentially be stored in block C1 created based on the first partitioning strategy P1 or in block C2 created based on the second partitioning strategy P2. Therefore, blocks C1 and C2 overlap so that the record can be mapped to both blocks C1 and C2. If the database system subsequently receives a query to process a specific record R, the database system 110 determines whether the record R is stored in a block created based on the first partitioning strategy P1 or the second partitioning strategy P2. Therefore, the database system 110 may have to check two possible blocks to determine where the record R is stored.
[0162] In some embodiments, the database system 110 creates new blocks that overlap with old blocks in terms of the time range used to partition the records. Thus, even after creating a new set of blocks in response to adding a new location, the database system may insert records into old blocks that were created before the location was added. While this may involve the old blocks (from the old view) continuing to see some portions of the new inserts - this may be mitigated based on the insertion strategy for overlapping blocks, e.g., one such strategy prefers to insert new records into blocks of smaller size - the overlap will not continue into future intervals. For example, continuing with the example above, when the database system creates a new block 9 hours into the interval of an existing block, it sets the start time and end time of the new block to be the same as the existing block (i.e., 9 hours earlier and 3 hours later). However, because the database system may adopt a strategy of writing blocks of smaller size, for example, even if the two sets have overlapping time periods, insertions will be made to new blocks rather than existing blocks.
[0163] In an implementation of the database system that uses a purely size-based approach to determining when to close chunks, these time interval issues do not arise, and the database system then simply closes existing chunks (even though the size of the existing chunks at the time of system reconfiguration may be less than a standard threshold size) and creates new chunks using the new partitioning strategy.
[0164] Because the new views may hold different sets of partitions, the database system may hold additional metadata that associates each of these reconfigurations to an "epoch." Specifically, each epoch may be associated with various information including a time period, a set of partitions, and a system view. Then, as described above, to determine the partitions of the hypertable at a particular time, the database system may need to first determine the epoch associated with that time, and then determine the partitions associated with that epoch. This process is described above in the context of the insertion method employed by the database system.
[0165] Computer architecture for database systems
[0166] Fig.12 is a diagram showing a method for using the Figure 1 12 is a high-level block diagram of an example of a computer 1200 with one or more of the entities shown. At least one processor 1202 is shown coupled to a memory controller hub 1220, which is also coupled to an input / output (I / O) controller hub 1222. Memory 1206 and a graphics adapter 1212 are coupled to the memory controller hub 1222, and a display device 1218 is coupled to the graphics adapter 1212. Storage devices 1208, keyboard 1210, pointing device 1214, and network adapter 1216 are coupled to the I / O controller hub. The storage devices may represent network attached disks, local and remote RAID, or SAN (storage area network). Storage devices 1208, keyboard 1210, pointing device 1214, and network adapter 1216 are coupled to the I / O controller hub 1222. Other embodiments of the computer 1200 have different architectures. For example, in some embodiments, the memory is directly coupled to the processor, and in other embodiments there are multiple different levels of memory coupled to different components. Some embodiments also include multiple processors coupled to each other or centrally coupled via a memory controller.
[0167] The storage device 1208 includes one or more non-transitory computer-readable storage media, such as one or more hard drives, compact disk read only memories (CD-ROMs), DVDs, or one or more solid-state memory devices. The memory holds instructions and data used by the processor 1202. The pointing device 1214 is used in conjunction with the keyboard to enter data into the computer 1200. The graphics adapter 1212 displays images and other information on the display device 1218. In some embodiments, the display device includes touch screen capabilities for receiving user input and selections. One or more network adapters 1216 couple the computer 1200 to a network. Some embodiments of the computer have a computer 1200 that is compatible with the computer 1200. Fig.12The components shown are different and / or other components. For example, the database system may include one or more servers that lack a display device, keyboard, pointing device, and other components, and the client device acting as the requestor may be a server, a workstation, a notebook or desktop computer, a tablet computer, an embedded device or a handheld device or a mobile phone, or other types of computing devices. The requestor of the database system may also be another process or program on the same computer on which the database system runs.
[0168] Computer 1200 is suitable for executing computer program modules for providing the functions described herein. As used herein, the term "module" refers to a computer program and / or other logic for providing a specified function. Therefore, a module can be implemented in hardware, firmware and / or software. In one embodiment, a program module formed by executable computer program instructions is stored on a storage device, loaded into a memory and executed by a processor.
[0169] Other considerations
[0170] In time series workloads, writes are typically made to the most recent time interval, rather than being distributed across many older time intervals. This enables the database system 110 to efficiently write batch inserts to a small number of tables, rather than performing many small writes across one giant table. In addition, the cluster architecture of the database system also utilizes time series workloads to the most recent time intervals to parallelize writes across many servers and / or disks to further support high data ingestion rates. These methods improve performance when employed on a variety of storage technologies including in-memory storage, hard disk drives (HDDs), or solid-state drives (SSDs).
[0171] Because the block size is adjusted to fit the server, and therefore the database system does not build a massive single table, the database system avoids or reduces swapping its indexes to disk for recent time intervals (where most writes typically occur). This occurs because the database system maintains a local index for each block; when a new record is inserted into a block, only the (smaller) index for the block needs to be updated, rather than a huge index built across the data of all hypertables. Therefore, for blocks associated with recent time intervals that are regularly accessed, the index for the block can be kept in memory, especially if the blocks are purposefully sized. However, the database system can still efficiently support many different types of indexes on different types of columns (e.g., as supported by per-node database engines such as PostgreSQL), including B-trees, B+ trees, GIN, GiST, SP-GiST, BRIN, hashes, LSM trees, fractal trees, and other types of indexes.
[0172] The database system combines transparent partitioning of its hypertable abstraction with a number of query optimizations. These optimizations include those for minimizing the number and set of chunks that must be touched to satisfy a query, reducing the amount of records returned from queries that touch chunks, specifying whether to return raw records or aggregated results from a chunk, and more.
[0173] Common queries on time series data include: (i) slicing across time for a given object (e.g., device id), slicing across many objects for a given time interval, or (iii) querying for the most recently reported data record across (a subset of) all objects or some other distinct object tag. While the user executes these queries as if interacting with a single hypertable, the database system leverages internally managed metadata to query only those chunks that are likely to satisfy the query predicate. By aggressively pruning the many chunks and servers to be contacted according to its query plan—or during execution when the system may have additional information—the database system improves both query latency and throughput.
[0174] Similarly, for items such as unique devices, users, or locations, a database system may receive a query such as "select the last K readings for each device." While this query can be naturally expressed in SQL using a "SELECT DISTINCT" query (to find the first or last single value for each distinct term) or through a window function (to find K such values), such a query can become a full table scan in many relational databases. In fact, this full table scan can continue back to the beginning of time to capture "for each device", or sacrifice completeness with some arbitrarily specified time range or involve a large WHERE clause or joins for some devices of interest (which can be maintained in a manual or automatic manner).
[0175] In some embodiments, the database system maintains additional metadata about the fields of the hypertable in order to optimize such queries. For example, the database system records information about each unique (distinct) value of the field in the database (e.g., the time interval, the latest row, or the block to which it belongs). The database system uses this metadata, as well as its other optimizations, so that such queries for different items avoid touching unnecessary blocks and perform efficient index queries for each individual block. The decision to maintain such metadata may be made manually or via automated means for a variety of reasons, including based on the type of field, the cardinality of different items of the field, query and workload patterns, etc.
[0176] The database system may perform other query optimizations that benefit both single-node and clustered deployments. When joining data from multiple tables (locally or across a network, e.g., via a foreign data wrapper), a traditional database may first select all data that matches the query predicate, optionally sort the data (ORDER), and then perform the requested restriction (LIMIT). Alternatively, the database system 110 first performs the query and post-processing (e.g., sorting and limiting) on each chunk, and then merges only the resulting collections from each chunk (after which it performs the final sort and limit).
[0177] The database system 110 pushes down limits for non-aggregate queries to minimize copying data across the network or reading unnecessary data from the table. The database system also pushes down aggregation for many common functions (e.g., SUM, AVG, MIN, MAX, COUNT) to the server where the block is located. Mainly, the advantage of cluster deployment, this distributed query optimization greatly minimizes network transmission by performing large aggregations or grouping by (GROUP_BY) in situ on the server of the block, so that only the calculation results need to be connected when the query is about to end instead of the original data from each block. Specifically, each node in the database system performs its own partial aggregation and then returns only the result to the requesting node.
[0178] For example, if a query to a database system requests some MAX, the first node processing the hypertable query sends a MAX query to the other nodes; each receiving node performs MAX on its own local block before sending the result back to the first node. The first node computes the MAX of these local maxima and returns that result. Similarly, if the hypertable query requests AVG, the first node sends queries to the other servers requesting the sum and count of some set of rows. These nodes can return their sum and count to the first node, which then computes the total average from these values (by dividing the sum of the sums by the sum of the counts).
[0179] The database system computes connections between the hypertables and standard relational tables. These standard tables may be stored directly in the database system or accessed from an external database, such as via a foreign data wrapper.
[0180] The database system 110 performs a join between two hypertables, including in many ways involving distributed optimizations, such as distributed joins. Such optimizations include optimizations that use hash-based partitioning, and optimizations that carefully minimize data duplication by sending only chunks from one hypertable to servers that have chunks of the other hypertable, depending on the join being performed, optionally using metadata associated with the chunks. Such optimizations also include periodically placing chunks of the hypertables being joined on servers in a manner that similar keys or key ranges are typically collocated on the same server, to minimize sending data over the network during the join.
[0181] The database system enables data retention policies to be easily defined based on time. For example, an administrator or user can use explicit commands or configure the system to clean / erase data older than X weeks. The chunking of the system also helps make such retention policies more efficient, because the database system then just discards the entire chunk (internal data table) that has expired rather than requiring individual rows to be deleted and the resulting table to be actively deleted, although the database system does support such row-based deletion.
[0182] For efficiency, the database system delays the implementation of such data retention policies. That is, depending on the policy or configuration, individual records that exceed the expiration time may not be deleted immediately. Instead, when all the data in the block expires, the entire block is discarded. Alternatively, the database system uses a mixture of discarding blocks and deleting individual rows when performing data deletion or complying with data retention policies.
[0183] The foregoing description of embodiments of the present invention has been presented for the purpose of illustration; the foregoing description is not intended to be exhaustive or to limit the invention to the precise form disclosed. In view of the above disclosure, those skilled in the relevant art may appreciate that many modifications and variations are possible.
[0184] The present invention also includes the following technical solutions:
[0185] Solution 1. A computer-implemented method comprising:
[0186] receiving, by a database system, an insert request, the insert request identifying a hypertable and one or more input records for insertion into the hypertable, each record having a plurality of attributes including a set of dimensional attributes, the set of dimensional attributes including a time attribute, wherein the hypertable represents a database table partitioned into a plurality of blocks along the set of dimensional attributes, each block being associated with a set of values corresponding to each dimensional attribute, such that for each record stored in the block, and for each dimensional attribute of the record, a value of the dimensional attribute of the record maps to a value from the set of values for the dimensional attribute specified by the block;
[0187] for each of the one or more input records, determining whether the input record should be stored in a new block to be created, the determination being based on a value of a dimension attribute of the input record;
[0188] In response to determining that the input record should be stored in a new block to be created, determining a set of values corresponding to each dimensional attribute of the new block to be created;
[0189] dynamically creating a new block for storing the input record, the new block being associated with the determined set of values corresponding to each dimension attribute;
[0190] updating the hypertable by storing the input record in the new block; and
[0191] Data stored in the updated hypertable is processed in response to one or more subsequent queries identifying the hypertable.
[0192] Option 2. The computer-implemented method of Option 1, wherein the database system stores data on a collection of one or more servers, wherein the plurality of blocks are distributed across one or more locations, wherein each location corresponds to one of:
[0193] a storage device added to a server from said set of servers used by said database system;
[0194] a storage device belonging to a new server, wherein the new server is added to the set of servers used by the database system; or
[0195] A network attached storage device of a remote server that is accessible to a server from the set of servers used by the database system.
[0196] Option 3. The computer-implemented method of Option 1, wherein determining that the input record should be stored in a new block is in response to determining that the input record cannot be stored in any existing block of the hypertable.
[0197] Solution 4. The computer-implemented method of solution 1, wherein determining a value set corresponding to each dimensional attribute of the new block comprises:
[0198] determining the size of one or more recently created chunks;
[0199] predicting the size of the new block based on the size of the most recently created block; and
[0200] A set of values corresponding to a dimensional attribute of the new block is determined based on one or more factors, including the predicted size of the new block.
[0201] Embodiment 5. The computer-implemented method of embodiment 1, wherein determining a value set corresponding to each dimensional attribute of the new block comprises:
[0202] determining that a size of one or more recently created chunks exceeds a threshold; and
[0203] Wherein, in response to determining that the size of the most recently created block exceeds the threshold, the value set corresponding to the dimension attribute is determined to have fewer elements than the value set corresponding to the dimension attribute of the most recently created block.
[0204] Embodiment 6. The computer-implemented method of embodiment 1, wherein determining a value set corresponding to each dimensional attribute of the new block comprises:
[0205] monitoring performance of one or more existing blocks; and
[0206] A set of values for a dimensional attribute corresponding to the new block is determined based on the monitored performance.
[0207] Embodiment 7. The computer-implemented method of embodiment 1, wherein determining a value set corresponding to each dimensional attribute of the new block comprises:
[0208] identifying a storage medium for storing the new block;
[0209] a property of access to the storage medium, the property describing a rate of access to data stored on the storage medium; and
[0210] A set of values corresponding to a dimensional attribute of the new block is determined based on the property of the storage medium.
[0211] Option 8. A computer-implemented method according to Option 1, wherein the set of dimension attributes includes a second attribute of the record, wherein the second attribute of the record describes an identifier of an entity associated with the record.
[0212] Option 9. The computer-implemented method of Option 1, wherein the hypertable is associated with one or more indexes, and the method further comprises: creating the one or more indexes for the new block.
[0213] Embodiment 10. The computer-implemented method of embodiment 1, wherein processing the data stored in the updated hypertable in response to one or more subsequent database queries identifying the hypertable comprises:
[0214] receiving a database query for processing data stored in the hypertable;
[0215] identifying a plurality of blocks of the hypertable, each of the plurality of blocks storing data that may be processed by the database query;
[0216] identifying one or more locations storing the plurality of chunks, each of the one or more locations comprising a storage device storing one or more chunks of the hypertable;
[0217] determining, for each of the one or more locations, partial results of the database query based on data stored in the location;
[0218] aggregating partial results corresponding to each of the one or more locations to determine an execution result of the database query; and
[0219] The execution result of the database query is sent.
[0220] Option 11. According to the computer-implemented method of Option 1, it also includes replicating blocks of the hypertable across multiple locations, wherein replicating the blocks includes inserting records into two or more copies of each block, wherein each copy is stored at a location different from the multiple locations.
[0221] Embodiment 12. The computer-implemented method of embodiment 11, wherein copying the block further comprises:
[0222] The number of replicas of the block is determined based on an age of the block, wherein if an age value of a first block is less than an age value of a second block, a greater number of replicas is maintained for the first block than for the second block.
[0223] Embodiment 13. The computer-implemented method of embodiment 11, wherein replicating a block of the hypertable further comprises:
[0224] A type of storage device used to store a copy of each block is determined based on the age of the block.
[0225] Embodiment 14. The computer-implemented method of embodiment 1, wherein each location is associated with a type and the supertable is associated with a threshold age value, the method further comprising:
[0226] identifying a block of the supertable having an age value greater than the threshold age value of the supertable; and
[0227] The identified block is moved from a first location having a first type to a second location having a second type.
[0228] Solution 15. A non-transitory computer-readable storage medium storing instructions for:
[0229] receiving, by a database system, an insert request, the insert request identifying a hypertable and one or more input records for insertion into the hypertable, each record having a plurality of attributes including a set of dimensional attributes, the set of dimensional attributes including a time attribute, wherein the hypertable represents a database table partitioned into a plurality of blocks along the set of dimensional attributes, each block being associated with a set of values corresponding to each dimensional attribute, such that for each record stored in the block, and for each dimensional attribute of the record, a value of the dimensional attribute of the record maps to a value from the set of values for the dimensional attribute specified by the block;
[0230] for each of the one or more input records, determining whether the input record should be stored in a new block to be created, the determination being based on a value of a dimension attribute of the input record;
[0231] In response to determining that the input record should be stored in a new block to be created, determining a set of values corresponding to each dimensional attribute of the new block to be created;
[0232] dynamically creating a new block for storing the input record, the new block being associated with the determined set of values corresponding to each dimension attribute;
[0233] updating the hypertable by storing the input record in the new block; and
[0234] Data stored in the updated hypertable is processed in response to one or more subsequent queries identifying the hypertable.
[0235] Embodiment 16. The non-transitory computer-readable storage medium of embodiment 15, wherein the database system stores data on a collection of one or more servers, wherein the plurality of blocks are distributed across one or more locations, and wherein each location corresponds to one of the following:
[0236] a storage device added to a server from said set of servers used by said database system;
[0237] a storage device belonging to a new server, wherein the new server is added to the set of servers used by the database system; or
[0238] A network attached storage device of a remote server that is accessible to a server from the set of servers used by the database system.
[0239] Embodiment 17. The non-transitory computer-readable storage medium of embodiment 15, wherein the instructions for determining a value set corresponding to each dimensional attribute of the new block include instructions for the following operations:
[0240] determining the size of one or more recently created chunks;
[0241] predicting the size of the new block based on the size of the most recently created block; and
[0242] A set of values corresponding to a dimensional attribute of the new block is determined based on one or more factors, including the predicted size of the new block.
[0243] Embodiment 18. The non-transitory computer-readable storage medium of embodiment 15, wherein the instructions for determining a value set corresponding to each dimensional attribute of the new block include instructions for the following operations:
[0244] determining that a size of one or more recently created chunks exceeds a threshold; and
[0245] Wherein, in response to determining that the size of the most recently created block exceeds the threshold, the value set corresponding to the dimension attribute is determined to have fewer elements than the value set corresponding to the dimension attribute of the most recently created block.
[0246] Embodiment 19. The non-transitory computer-readable storage medium of embodiment 15, wherein the instructions for determining a value set corresponding to each dimensional attribute of the new block include instructions for the following operations:
[0247] monitoring performance of one or more existing blocks; and
[0248] A set of values for a dimensional attribute corresponding to the new block is determined based on the monitored performance.
[0249] Embodiment 20. The non-transitory computer-readable storage medium of embodiment 15, wherein the instructions for determining a value set corresponding to each dimensional attribute of the new block include instructions for the following operations:
[0250] identifying a storage medium for storing the new block;
[0251] a property of access to the storage medium, the property describing a rate of access to data stored on the storage medium; and
[0252] A set of values corresponding to a dimensional attribute of the new block is determined based on the property of the storage medium.
[0253] Embodiment 21. The non-transitory computer-readable storage medium of embodiment 15, wherein the instructions for processing the data stored in the updated hypertable in response to one or more subsequent database queries identifying the hypertable include instructions for:
[0254] receiving a database query for processing data stored in the hypertable;
[0255] identifying a plurality of blocks of the hypertable, each of the plurality of blocks storing data that may be processed by the database query;
[0256] identifying one or more locations storing the plurality of chunks, each of the one or more locations comprising a storage device storing one or more chunks of the hypertable;
[0257] determining, for each of the one or more locations, partial results of the database query based on data stored in the location;
[0258] aggregating partial results corresponding to each of the one or more locations to determine an execution result of the database query; and
[0259] The execution result of the database query is sent.
[0260] Solution 22. A computer system comprising:
[0261] one or more processors; and
[0262] A non-transitory computer-readable storage medium storing instructions for execution by the one or more processors, the instructions for:
[0263] receiving, by a database system, an insert request, the insert request identifying a hypertable and one or more input records for insertion into the hypertable, each record having a plurality of attributes including a set of dimensional attributes, the set of dimensional attributes including a time attribute, wherein the hypertable represents a database table partitioned into a plurality of blocks along the set of dimensional attributes, each block being associated with a set of values corresponding to each dimensional attribute, such that for each record stored in the block, and for each dimensional attribute of the record, a value of the dimensional attribute of the record maps to a value from the set of values for the dimensional attribute specified by the block;
[0264] for each of the one or more input records, determining whether the input record should be stored in a new block to be created, the determination being based on a value of a dimension attribute of the input record;
[0265] In response to determining that the input record should be stored in a new block to be created, determining a value set corresponding to each dimensional attribute of the new block to be created;
[0266] dynamically creating a new block for storing the input record, the new block being associated with the determined set of values corresponding to each dimension attribute;
[0267] updating the hypertable by storing the input record in the new block; and processing the data stored in the updated hypertable in response to one or more subsequent queries identifying the hypertable.
[0268] Solution 23. The computer system of Solution 22, wherein the database system stores data on a collection of one or more servers, wherein the plurality of blocks are distributed across one or more locations, and wherein each location corresponds to one of the following:
[0269] a storage device added to a server from said set of servers used by said database system;
[0270] a storage device belonging to a new server, wherein the new server is added to the set of servers used by the database system; or
[0271] A network attached storage device of a remote server that is accessible to a server from the set of servers used by the database system.
[0272] Solution 24. The computer system of solution 22, wherein the instructions for determining a value set corresponding to each dimension attribute of the new block include instructions for the following operations:
[0273] determining the size of one or more recently created chunks;
[0274] predicting the size of the new block based on the size of the most recently created block; and
[0275] A set of values corresponding to a dimensional attribute of the new block is determined based on one or more factors, including the predicted size of the new block.
[0276] Solution 25. The computer system of solution 22, wherein the instructions for determining a value set corresponding to each dimension attribute of the new block include instructions for the following operations:
[0277] determining that a size of one or more recently created chunks exceeds a threshold; and
[0278] Wherein, in response to determining that the size of the most recently created block exceeds the threshold, the value set corresponding to the dimension attribute is determined to have fewer elements than the value set corresponding to the dimension attribute of the most recently created block.
[0279] Solution 26. The computer system of solution 22, wherein the instructions for determining a value set corresponding to each dimensional attribute of the new block include instructions for the following operations:
[0280] monitoring performance of one or more existing blocks; and
[0281] A set of values for a dimensional attribute corresponding to the new block is determined based on the monitored performance.
[0282] Solution 27. The computer system of solution 22, wherein the instructions for determining a value set corresponding to each dimensional attribute of the new block include instructions for the following operations:
[0283] identifying a storage medium for storing the new block;
[0284] a property of access to the storage medium, the property describing a rate of access to data stored on the storage medium; and
[0285] A set of values corresponding to a dimensional attribute of the new block is determined based on the property of the storage medium.
[0286] Embodiment 28. The computer system of embodiment 22, wherein the instructions for processing the data stored in the updated hypertable in response to one or more subsequent database queries identifying the hypertable include instructions for:
[0287] receiving a database query for processing data stored in the hypertable;
[0288] identifying a plurality of blocks of the hypertable, each of the plurality of blocks storing data that may be processed by the database query;
[0289] identifying one or more locations storing the plurality of chunks, each of the one or more locations comprising a storage device storing one or more chunks of the hypertable;
[0290] determining, for each of the one or more locations, partial results of the database query based on data stored in the location;
[0291] aggregating partial results corresponding to each of the one or more locations to determine an execution result of the database query; and
[0292] The execution result of the database query is sent.
[0293] Embodiment 29. A computer-implemented method comprising:
[0294] Receiving, by a database system, a first insert request identifying a hypertable and one or more input records to be inserted into the hypertable, each record having a plurality of attributes including a set of dimensional attributes, the set of dimensional attributes including a time attribute, wherein the hypertable represents a database table partitioned into blocks along the set of dimensional attributes, the blocks being distributed across a first plurality of locations, wherein each location comprises a different storage device and each block is associated with a set of values corresponding to each dimensional attribute, such that for each record stored in the block, and for each dimensional attribute of the record, a value of the dimensional attribute of the record maps to a value from the set of values for the dimensional attribute specified by the block;
[0295] In response to receiving the first insert request for inserting the record into the hypertable, storing the one or more records specified in the first insert request in blocks created according to a first partitioning strategy, the first partitioning strategy specifying sizes of a first plurality of blocks to be created and a mapping from each of the first plurality of blocks to a location from the first plurality of locations for storing the block, wherein each of the one or more records is inserted into a block from the first plurality of blocks based on a value of a dimensional attribute of the record;
[0296] receiving an indication to add one or more new locations to the database system, the addition causing the database system to have a second plurality of locations, wherein the indication is associated with a reconfiguration time;
[0297] creating a second plurality of blocks after receiving the indication to add the one or more new locations, the second plurality of blocks being created according to a second partitioning strategy, the second partitioning strategy specifying a size of the second plurality of blocks to be created and a mapping from each of the second plurality of blocks to a location from the second plurality of locations, and wherein, after receiving the indication to add the one or more new locations, maintaining a distribution of the first plurality of blocks according to the first partitioning strategy;
[0298] receiving a second insert request to insert one or more records into the database table after receiving the indication to add one or more new locations to the database system; and
[0299] In response to receiving the second insert request, for each of the one or more records specified in the second insert request, the record is stored in a block selected based on a value of a dimension attribute of the record.
[0300] Scheme 30. A computer-implemented method according to Scheme 29, wherein each of the first partitioning strategy and the second partitioning strategy further specifies a configuration of blocks created according to the partitioning strategy, the configuration of each block specifies a value set corresponding to each dimensional attribute, so that for each record stored in the block, and for each dimensional attribute of the record, the value of the dimensional attribute of the record is mapped to a value from the value set of the dimensional attribute specified by the block.
[0301] Embodiment 31. The computer-implemented method of embodiment 29, wherein, in response to receiving the second insert request, for each of the one or more records specified in the second insert request, in response to determining that the record cannot be inserted into an existing block, creating a block, the creating comprising:
[0302] determining that a time attribute of the record specified in the second insert request has a time value before the reconfiguration time; and
[0303] In response to determining that the time attribute of the record has a time value before the reconfiguration time, a chunk is created based on the first partitioning strategy.
[0304] Embodiment 32. The computer-implemented method of embodiment 29, wherein, in response to receiving the second insert request, for each of the one or more records specified in the second insert request, in response to determining that the record cannot be inserted into an existing block, creating a block, the creating comprising:
[0305] determining that a time attribute of the record specified in the second insert request has a time value after the reconfiguration time; and
[0306] In response to determining that the time attribute of the record has a time value after the reconfiguration time, a chunk is created according to the second partitioning strategy.
[0307] Embodiment 33. The computer-implemented method of embodiment 29, wherein, in response to receiving the second insert request, for each of the one or more records specified in the second insert request, in response to determining that the record cannot be inserted into an existing block, creating a block, the creating comprising:
[0308] determining that the second insert request is received at a time greater than the reconfiguration time; and
[0309] In response to determining that the second insert request is received at a time greater than the reconfiguration time, a block for inserting the record is created based on the second partitioning strategy independent of a value of a time attribute of the record.
[0310] Embodiment 34. The computer-implemented method of embodiment 29 further comprising:
[0311] receiving a query for processing records having time attribute values prior to the reconfiguration time;
[0312] determining whether the record is stored in a block created based on a specific partitioning strategy selected from the first partitioning strategy and the second partitioning strategy; and
[0313] In response to failing to identify a block storing the record and created based on the particular partitioning strategy, determining whether the block for storing the record is created based on another partitioning strategy selected from the first partitioning strategy and the second partitioning strategy.
[0314] Option 35. A computer-implemented method according to Option 29, wherein the second partitioning strategy assigns blocks from the second plurality of blocks to locations from the second plurality of locations so that more blocks from the second plurality of blocks are assigned to new locations than to locations belonging to the first plurality of locations.
[0315] Option 36. A computer-implemented method according to Option 29, wherein the second partitioning strategy assigns a block from the second plurality of blocks to a location from the second plurality of locations such that a first block assigned to a new location is configured to store more data than a second block assigned to a location belonging to the first plurality of locations.
[0316] Embodiment 37. The computer-implemented method of embodiment 29 further comprising:
[0317] A number of blocks in the second plurality of blocks is determined based on the number of positions in the second plurality of positions.
[0318] Embodiment 38. The computer-implemented method of embodiment 29 further comprising:
[0319] A configuration of each block in the second plurality of blocks is determined based on the number of positions in the second plurality of positions, the configuration specifying a value set for a dimensional attribute of the block such that, for each record stored in the block, and for each dimensional attribute of the record, the value of the dimensional attribute of the record maps to a value from the value set for the dimensional attribute specified by the block.
[0320] Embodiment 39. The computer-implemented method of embodiment 29, wherein the database system stores data on a collection of one or more servers, and wherein the new location represents one of the following:
[0321] adding a storage device of a server from said set of servers;
[0322] a storage device belonging to a new server, wherein the new server is added to the set of servers used by the database system; or
[0323] A network attached storage device of the remote server that is accessible to a server from the set of servers.
[0324] Embodiment 40. A non-transitory computer-readable storage medium storing instructions for:
[0325] Receiving, by a database system, a first insert request identifying a hypertable and one or more input records to be inserted into the hypertable, each record having a plurality of attributes including a set of dimensional attributes, the set of dimensional attributes including a time attribute, wherein the hypertable represents a database table partitioned into blocks along the set of dimensional attributes, the blocks being distributed across a first plurality of locations, wherein each location comprises a different storage device and each block is associated with a set of values corresponding to each dimensional attribute, such that for each record stored in the block, and for each dimensional attribute of the record, a value of the dimensional attribute of the record maps to a value from the set of values for the dimensional attribute specified by the block;
[0326] In response to receiving the first insert request for inserting the record into the hypertable, storing the one or more records specified in the first insert request in blocks created according to a first partitioning strategy, the first partitioning strategy specifying sizes of a first plurality of blocks to be created and a mapping from each of the first plurality of blocks to a location from the first plurality of locations for storing the block, wherein each of the one or more records is inserted into a block from the first plurality of blocks based on a value of a dimensional attribute of the record;
[0327] receiving an indication to add one or more new locations to the database system, the addition causing the database system to have a second plurality of locations, wherein the indication is associated with a reconfiguration time;
[0328] creating a second plurality of blocks after receiving the indication to add the one or more new locations, the second plurality of blocks being created according to a second partitioning strategy, the second partitioning strategy specifying a size of the second plurality of blocks to be created and a mapping from each of the second plurality of blocks to a location from the second plurality of locations, and wherein, after receiving the indication to add the one or more new locations, maintaining a distribution of the first plurality of blocks according to the first partitioning strategy;
[0329] receiving a second insert request to insert one or more records into the database table after receiving the indication to add one or more new locations to the database system; and
[0330] In response to receiving the second insert request, for each of the one or more records specified in the second insert request, the record is stored in a block selected based on a value of a dimension attribute of the record.
[0331] Scheme 41. A non-transitory computer-readable storage medium according to Scheme 40, wherein each of the first partitioning strategy and the second partitioning strategy further specifies a configuration of a block created according to the partitioning strategy, the configuration of each block specifies a value set corresponding to each dimensional attribute, so that for each record stored in the block, and for each dimensional attribute of the record, the value of the dimensional attribute of the record is mapped to a value from the value set of the dimensional attribute specified by the block.
[0332] Embodiment 42. The non-transitory computer-readable storage medium according to embodiment 40, wherein the stored instructions are further used for the following operations:
[0333] receiving a query for processing records having time attribute values prior to the reconfiguration time;
[0334] determining whether the record is stored in a block created based on a specific partitioning strategy selected from the first partitioning strategy and the second partitioning strategy; and
[0335] In response to failing to identify a block storing the record and created based on the particular partitioning strategy, determining whether the block for storing the record is created based on another partitioning strategy selected from the first partitioning strategy and the second partitioning strategy.
[0336] Option 43. A non-transitory computer-readable storage medium according to Option 40, wherein the second partitioning strategy assigns blocks from the second plurality of blocks to locations from the second plurality of locations, so that more blocks from the second plurality of blocks are assigned to new locations than to locations belonging to the first plurality of locations.
[0337] Option 44. A non-transitory computer-readable storage medium according to Option 40, wherein the second partitioning strategy assigns a block from the second plurality of blocks to a location from the second plurality of locations, so that a first block assigned to a new location is configured to store more data than a second block assigned to a location belonging to the first plurality of locations.
[0338] Embodiment 45. The non-transitory computer-readable storage medium according to embodiment 40, wherein the stored instructions are further used for the following operations:
[0339] A number of blocks in the second plurality of blocks is determined based on the number of positions in the second plurality of positions.
[0340] Embodiment 46. The non-transitory computer-readable storage medium according to embodiment 40 further comprising:
[0341] A configuration of each block in the second plurality of blocks is determined based on the number of positions in the second plurality of positions, the configuration specifying a value set for a dimensional attribute of the block such that, for each record stored in the block, and for each dimensional attribute of the record, the value of the dimensional attribute of the record maps to a value from the value set for the dimensional attribute specified by the block.
[0342] Embodiment 47. The non-transitory computer-readable storage medium of embodiment 40, wherein the database system stores data on a collection of one or more servers, and wherein the new location represents one of the following:
[0343] adding a storage device of a server from said set of servers;
[0344] a storage device belonging to a new server, wherein the new server is added to the set of servers used by the database system; or
[0345] A network attached storage device of the remote server that is accessible to a server from the set of servers.
[0346] Solution 48. A computer system comprising:
[0347] one or more processors; and
[0348] A non-transitory computer-readable storage medium storing instructions for execution by the one or more processors, the instructions for:
[0349] Receiving, by a database system, a first insert request identifying a hypertable and one or more input records to be inserted into the hypertable, each record having a plurality of attributes including a set of dimensional attributes, the set of dimensional attributes including a time attribute, wherein the hypertable represents a database table partitioned into blocks along the set of dimensional attributes, the blocks being distributed across a first plurality of locations, wherein each location comprises a different storage device and each block is associated with a set of values corresponding to each dimensional attribute, such that for each record stored in the block, and for each dimensional attribute of the record, a value of the dimensional attribute of the record maps to a value from the set of values for the dimensional attribute specified by the block;
[0350] In response to receiving the first insert request for inserting the record into the hypertable, storing the one or more records specified in the first insert request in blocks created according to a first partitioning strategy, the first partitioning strategy specifying sizes of a first plurality of blocks to be created and a mapping from each of the first plurality of blocks to a location from the first plurality of locations for storing the block, wherein each of the one or more records is inserted into a block from the first plurality of blocks based on a value of a dimensional attribute of the record;
[0351] receiving an indication to add one or more new locations to the database system, the addition causing the database system to have a second plurality of locations, wherein the indication is associated with a reconfiguration time;
[0352] creating a second plurality of blocks after receiving the indication to add the one or more new locations, the second plurality of blocks being created according to a second partitioning strategy, the second partitioning strategy specifying a size of the second plurality of blocks to be created and a mapping from each of the second plurality of blocks to a location from the second plurality of locations, and wherein, after receiving the indication to add the one or more new locations, maintaining a distribution of the first plurality of blocks according to the first partitioning strategy;
[0353] receiving a second insert request to insert one or more records into the database table after receiving the indication to add one or more new locations to the database system; and
[0354] In response to receiving the second insert request, for each of the one or more records specified in the second insert request, the record is stored in a block selected based on a value of a dimension attribute of the record.
[0355] Scheme 49. A computer system according to Scheme 48, wherein each of the first partitioning strategy and the second partitioning strategy further specifies a configuration of blocks created according to the partitioning strategy, the configuration of each block specifies a value set corresponding to each dimensional attribute, so that for each record stored in the block, and for each dimensional attribute of the record, the value of the dimensional attribute of the record is mapped to a value from the value set of the dimensional attribute specified by the block.
[0356] Solution 50. The computer system according to Solution 48, wherein the stored instructions are further used for the following operations:
[0357] receiving a query for processing records having time attribute values prior to the reconfiguration time;
[0358] determining whether the record is stored in a block created based on a specific partitioning strategy selected from the first partitioning strategy and the second partitioning strategy; and
[0359] In response to failing to identify a block storing the record and created based on the particular partitioning strategy, determining whether the block for storing the record is created based on another partitioning strategy selected from the first partitioning strategy and the second partitioning strategy.
[0360] Option 51. A computer system according to Option 48, wherein the second partitioning strategy assigns blocks from the second plurality of blocks to locations from the second plurality of locations, so that more blocks from the second plurality of blocks are assigned to new locations than to locations belonging to the first plurality of locations.
[0361] Option 52. A computer system according to Option 48, wherein the second partitioning strategy assigns a block from the second plurality of blocks to a location from the second plurality of locations, so that a first block assigned to a new location is configured to store more data than a second block assigned to a location belonging to the first plurality of locations.
[0362] Solution 53. A computer system according to Solution 48, wherein the stored instructions are further used for the following operations:
[0363] A number of blocks in the second plurality of blocks is determined based on the number of positions in the second plurality of positions.
[0364] Solution 54. The computer system according to Solution 48, further comprising:
[0365] A configuration of each block in the second plurality of blocks is determined based on the number of positions in the second plurality of positions, the configuration specifying a value set for a dimensional attribute of the block such that, for each record stored in the block, and for each dimensional attribute of the record, the value of the dimensional attribute of the record maps to a value from the value set for the dimensional attribute specified by the block.
[0366] Embodiment 55. The computer system of embodiment 48, wherein the database system stores data on a collection of one or more servers, and wherein the new location represents one of the following:
[0367] adding a storage device of a server from said set of servers;
[0368] a storage device belonging to a new server, wherein the new server is added to the set of servers used by the database system; or
[0369] A network attached storage device of the remote server that is accessible to a server from the set of servers.
[0370] Some parts of this specification describe embodiments of the present invention from the aspect of algorithms and symbolic representations of operations on information. Those skilled in the art of data processing typically use these algorithmic descriptions and representations to effectively convey the essence of their work to other technicians in the field. Although these operations are described functionally, computationally, or logically, they should be understood to be implemented by computer programs or equivalent circuits, microcodes, etc. In addition, it has been proven to be convenient sometimes to refer to these operational arrangements as modules without loss of generality. The described operations and their associated modules can be implemented in software, firmware, hardware, or any combination thereof.
[0371] Any step, operation or process described herein may be performed or implemented using one or more hardware or software modules alone or in combination with other devices. In one embodiment, the software module is implemented using a computer program product including a computer-readable medium, which contains computer program code that can be executed by a computer processor to perform any or all of the steps, operations or processes.
[0372] Embodiments of the present invention may also relate to an apparatus for performing the operations herein. The apparatus may be specially constructed for the desired purpose and / or the apparatus may include a general-purpose computing device selectively activated or reconfigured by a computer program stored in a computer. Such a computer program may be stored in a tangible computer-readable storage medium or any type of medium suitable for storing electronic instructions and coupled to a computer system bus. In addition, any computing system mentioned in the specification may include a single processor or may be an architecture using a multi-processor design to increase computing power.
[0373] Finally, the language used in the specification is primarily selected for readability and instructional purposes, and the language may not be selected to describe or limit the subject matter of the present invention. Therefore, the scope of the present invention is not intended to be limited by this detailed description, but by any claims issued on an application based thereon. Therefore, the disclosure of the embodiments of the present invention is intended to be illustrative rather than limiting the scope of the present invention.
Claims
1. A computer-implemented method comprising: Receiving, by a database system, a first insert request identifying a hypertable and one or more input records to be inserted into the hypertable, each record having a plurality of attributes including a set of dimensional attributes, the set of dimensional attributes including a time attribute, wherein the hypertable represents a database table partitioned into blocks along the set of dimensional attributes, the blocks being distributed across a first plurality of locations, wherein each location comprises a different storage device and each block is associated with a set of values corresponding to each dimensional attribute, such that for each record stored in the block, and for each dimensional attribute of the record, a value of the dimensional attribute of the record maps to a value from the set of values for the dimensional attribute specified by the block; In response to receiving the first insert request for inserting the record into the hypertable, storing the one or more records specified in the first insert request in blocks created according to a first partitioning strategy, the first partitioning strategy specifying sizes of a first plurality of blocks to be created and a mapping from each of the first plurality of blocks to a location from the first plurality of locations for storing the block, wherein each of the one or more records is inserted into a block from the first plurality of blocks based on a value of a dimensional attribute of the record; receiving an indication to add one or more new locations to the database system, the addition causing the database system to have a second plurality of locations, wherein the indication is associated with a reconfiguration time; creating a second plurality of blocks after receiving the indication to add the one or more new locations, the second plurality of blocks being created according to a second partitioning strategy, the second partitioning strategy specifying a size of the second plurality of blocks to be created and a mapping from each of the second plurality of blocks to a location from the second plurality of locations, and wherein, after receiving the indication to add the one or more new locations, maintaining a distribution of the first plurality of blocks according to the first partitioning strategy; After receiving the indication to add one or more new locations to the database system, receiving a second insert request to insert one or more records into the database table; and In response to receiving the second insert request, for each of the one or more records specified in the second insert request, the record is stored in a block selected based on a value of a dimension attribute of the record.
2. The computer-implemented method of claim 1 , wherein: Each of the first partitioning strategy and the second partitioning strategy also specifies a configuration of blocks created according to the partitioning strategy, the configuration of each block specifying a value set corresponding to each dimensional attribute, so that for each record stored in the block, and for each dimensional attribute of the record, the value of the dimensional attribute of the record is mapped to a value from the value set of the dimensional attribute specified by the block.
3. The computer-implemented method of claim 1 , wherein: In response to receiving the second insert request, for each of the one or more records specified in the second insert request, in response to determining that the record cannot be inserted into an existing block, creating a block, the creating comprising: determining that a time attribute of the record specified in the second insert request has a time value before the reconfiguration time; and In response to determining that the time attribute of the record has a time value before the reconfiguration time, a chunk is created based on the first partitioning strategy.
4. The computer-implemented method of claim 1 , wherein: In response to receiving the second insert request, for each of the one or more records specified in the second insert request, in response to determining that the record cannot be inserted into an existing block, creating a block, the creating comprising: determining that a time attribute of the record specified in the second insert request has a time value after the reconfiguration time; and In response to determining that the time attribute of the record has a time value after the reconfiguration time, a chunk is created according to the second partitioning strategy.
5. The computer-implemented method of claim 1 , wherein: In response to receiving the second insert request, for each of the one or more records specified in the second insert request, in response to determining that the record cannot be inserted into an existing block, creating a block, the creating comprising: determining that the second insert request is received at a time greater than the reconfiguration time; and In response to determining that the second insert request is received at a time greater than the reconfiguration time, a block for inserting the record is created based on the second partitioning strategy independent of a value of a time attribute of the record.
6. The computer-implemented method of claim 1 , further comprising: receiving a query for processing records having time attribute values prior to the reconfiguration time; determining whether the record is stored in a block created based on a specific partitioning strategy selected from the first partitioning strategy and the second partitioning strategy; as well as In response to failing to identify a block storing the record and created based on the particular partitioning strategy, determining whether the block for storing the record is created based on another partitioning strategy selected from the first partitioning strategy and the second partitioning strategy.
7. The computer-implemented method of claim 1 , wherein: The second partitioning strategy assigns blocks from the second plurality of blocks to locations from the second plurality of locations such that more blocks from the second plurality of blocks are assigned to new locations than to locations belonging to the first plurality of locations.
8. The computer-implemented method of claim 1 , wherein: The second partitioning strategy assigns a block from the second plurality of blocks to a location from the second plurality of locations such that a first block assigned to a new location is configured to store more data than a second block assigned to a location belonging to the first plurality of locations.
9. The computer-implemented method of claim 1 , further comprising: A number of blocks in the second plurality of blocks is determined based on the number of positions in the second plurality of positions.
10. The computer-implemented method of claim 1 , further comprising: A configuration of each block in the second plurality of blocks is determined based on the number of positions in the second plurality of positions, the configuration specifying a value set for a dimensional attribute of the block such that, for each record stored in the block, and for each dimensional attribute of the record, the value of the dimensional attribute of the record maps to a value from the value set for the dimensional attribute specified by the block.
11. The computer-implemented method of claim 1 , wherein: The database system stores data on a collection of one or more servers, and wherein the new location represents one of the following: adding a storage device of a server from said set of servers; a storage device belonging to a new server, wherein the new server is added to the set of servers used by the database system; or A network attached storage device of the remote server that is accessible to a server from the set of servers.
12. A non-transitory computer-readable storage medium storing instructions for: Receiving, by a database system, a first insert request identifying a hypertable and one or more input records for inserting into the hypertable, each record having a plurality of attributes including a set of dimensional attributes, the set of dimensional attributes including a time attribute, wherein: The hypertable represents a database table partitioned into chunks along the set of dimensional attributes, the chunks being distributed across a first plurality of locations, wherein each location comprises a different storage device and each chunk is associated with a set of values corresponding to each dimensional attribute, such that for each record stored in the chunk, and for each dimensional attribute of the record, a value of the dimensional attribute of the record maps to a value from the set of values for the dimensional attribute specified by the chunk; In response to receiving the first insert request for inserting the record into the hypertable, storing the one or more records specified in the first insert request in blocks created according to a first partitioning strategy, the first partitioning strategy specifying sizes of a first plurality of blocks to be created and a mapping from each of the first plurality of blocks to a location from the first plurality of locations for storing the block, wherein each of the one or more records is inserted into a block from the first plurality of blocks based on a value of a dimensional attribute of the record; receiving an indication to add one or more new locations to the database system, the addition causing the database system to have a second plurality of locations, wherein the indication is associated with a reconfiguration time; creating a second plurality of blocks after receiving the indication to add the one or more new locations, the second plurality of blocks being created according to a second partitioning strategy, the second partitioning strategy specifying a size of the second plurality of blocks to be created and a mapping from each of the second plurality of blocks to a location from the second plurality of locations, and wherein, after receiving the indication to add the one or more new locations, maintaining a distribution of the first plurality of blocks according to the first partitioning strategy; receiving a second insert request to insert one or more records into the database table after receiving the indication to add one or more new locations to the database system; and In response to receiving the second insert request, for each of the one or more records specified in the second insert request, the record is stored in a block selected based on a value of a dimension attribute of the record.
13. The non-transitory computer-readable storage medium of claim 12, wherein: Each of the first partitioning strategy and the second partitioning strategy also specifies a configuration of blocks created according to the partitioning strategy, the configuration of each block specifying a value set corresponding to each dimensional attribute, so that for each record stored in the block, and for each dimensional attribute of the record, the value of the dimensional attribute of the record is mapped to a value from the value set of the dimensional attribute specified by the block.
14. The non-transitory computer-readable storage medium of claim 12, wherein: The stored instructions are also used for the following operations: receiving a query for processing records having time attribute values prior to the reconfiguration time; determining whether the record is stored in a block created based on a specific partitioning strategy selected from the first partitioning strategy and the second partitioning strategy; as well as In response to failing to identify a block storing the record and created based on the particular partitioning strategy, determining whether the block for storing the record is created based on another partitioning strategy selected from the first partitioning strategy and the second partitioning strategy.
15. The non-transitory computer-readable storage medium of claim 12, wherein: The second partitioning strategy assigns blocks from the second plurality of blocks to locations from the second plurality of locations such that more blocks from the second plurality of blocks are assigned to new locations than to locations belonging to the first plurality of locations.
16. The non-transitory computer readable storage medium of claim 12, wherein: The second partitioning strategy assigns a block from the second plurality of blocks to a location from the second plurality of locations such that a first block assigned to a new location is configured to store more data than a second block assigned to a location belonging to the first plurality of locations.
17. The non-transitory computer-readable storage medium of claim 12, wherein: The stored instructions are also used for the following operations: A number of blocks in the second plurality of blocks is determined based on the number of positions in the second plurality of positions.
18. The non-transitory computer-readable storage medium of claim 12, further comprising: A configuration of each block in the second plurality of blocks is determined based on the number of positions in the second plurality of positions, the configuration specifying a value set for a dimensional attribute of the block such that, for each record stored in the block, and for each dimensional attribute of the record, the value of the dimensional attribute of the record maps to a value from the value set for the dimensional attribute specified by the block.
19. The non-transitory computer-readable storage medium of claim 12, wherein: The database system stores data on a collection of one or more servers, and wherein the new location represents one of the following: adding a storage device of a server from said set of servers; a storage device belonging to a new server, wherein the new server is added to the set of servers used by the database system; or A network attached storage device of the remote server that is accessible to a server from the set of servers.
20. A computer system comprising: one or more processors; as well as A non-transitory computer-readable storage medium storing instructions for execution by the one or more processors, the instructions for: Receiving, by a database system, a first insert request identifying a hypertable and one or more input records to be inserted into the hypertable, each record having a plurality of attributes including a set of dimensional attributes, the set of dimensional attributes including a time attribute, wherein the hypertable represents a database table partitioned into blocks along the set of dimensional attributes, the blocks being distributed across a first plurality of locations, wherein each location comprises a different storage device and each block is associated with a set of values corresponding to each dimensional attribute, such that for each record stored in the block, and for each dimensional attribute of the record, a value of the dimensional attribute of the record maps to a value from the set of values for the dimensional attribute specified by the block; In response to receiving the first insert request for inserting the record into the hypertable, storing the one or more records specified in the first insert request in blocks created according to a first partitioning strategy, the first partitioning strategy specifying sizes of a first plurality of blocks to be created and a mapping from each of the first plurality of blocks to a location from the first plurality of locations for storing the block, wherein each of the one or more records is inserted into a block from the first plurality of blocks based on a value of a dimensional attribute of the record; receiving an indication to add one or more new locations to the database system, the addition causing the database system to have a second plurality of locations, wherein the indication is associated with a reconfiguration time; creating a second plurality of blocks after receiving the indication to add the one or more new locations, the second plurality of blocks being created according to a second partitioning strategy, the second partitioning strategy specifying a size of the second plurality of blocks to be created and a mapping from each of the second plurality of blocks to a location from the second plurality of locations, and wherein, after receiving the indication to add the one or more new locations, maintaining a distribution of the first plurality of blocks according to the first partitioning strategy; receiving a second insert request to insert one or more records into the database table after receiving the indication to add one or more new locations to the database system; and In response to receiving the second insert request, for each of the one or more records specified in the second insert request, the record is stored in a block selected based on a value of a dimension attribute of the record.
21. The computer system of claim 20, wherein: Each of the first partitioning strategy and the second partitioning strategy also specifies a configuration of blocks created according to the partitioning strategy, the configuration of each block specifying a value set corresponding to each dimensional attribute, so that for each record stored in the block, and for each dimensional attribute of the record, the value of the dimensional attribute of the record is mapped to a value from the value set of the dimensional attribute specified by the block.
22. The computer system of claim 20, wherein: The stored instructions are also used for the following operations: receiving a query for processing records having time attribute values prior to the reconfiguration time; determining whether the record is stored in a block created based on a specific partitioning strategy selected from the first partitioning strategy and the second partitioning strategy; as well as In response to failing to identify a block storing the record and created based on the particular partitioning strategy, determining whether the block for storing the record is created based on another partitioning strategy selected from the first partitioning strategy and the second partitioning strategy.
23. The computer system of claim 20, wherein: The second partitioning strategy assigns blocks from the second plurality of blocks to locations from the second plurality of locations such that more blocks from the second plurality of blocks are assigned to new locations than to locations belonging to the first plurality of locations.
24. The computer system of claim 20, wherein: The second partitioning strategy assigns a block from the second plurality of blocks to a location from the second plurality of locations such that a first block assigned to a new location is configured to store more data than a second block assigned to a location belonging to the first plurality of locations.
25. The computer system of claim 20, wherein: The stored instructions are also used for the following operations: A number of blocks in the second plurality of blocks is determined based on the number of positions in the second plurality of positions.
26. The computer system of claim 20, further comprising: A configuration of each block in the second plurality of blocks is determined based on the number of positions in the second plurality of positions, the configuration specifying a value set for a dimensional attribute of the block such that, for each record stored in the block, and for each dimensional attribute of the record, the value of the dimensional attribute of the record maps to a value from the value set for the dimensional attribute specified by the block.
27. The computer system of claim 20, wherein: The database system stores data on a collection of one or more servers, and wherein the new location represents one of the following: adding a storage device of a server from said set of servers; a storage device belonging to a new server, wherein the new server is added to the set of servers used by the database system; or A network attached storage device of the remote server that is accessible to a server from the set of servers.
Citation Information
Patent Citations
Data extensibility using external database table
CN101000612A
Method for partitioning database and system thereof
CN101876983A
