The present disclosure relates to techniques for processing graphs. More specifically, the disclosure relates to fast and memory efficient in-memory columnar graph updates while preserving analytical performance.
The approaches described in this section are approaches that could be pursued, but not necessarily approaches that have been previously conceived or pursued. Therefore, unless otherwise indicated, it should not be assumed that any of the approaches described in this section qualify as prior art merely by virtue of their inclusion in this section.
There exist challenges to updating a graph stored in an in-memory graph database or graph processing engine while providing snapshot isolation guarantees and maintaining analytical performance on the graph. For example, most graph processing engines and graph databases use special indices to accelerate the graph traversals when performing graph analytics or answering graph queries. However, it is difficult to modify these data structures to have fast updates while maintaining the performance during graph analytics and querying. Maintaining snapshot isolation—meaning adding the requirement that a user should be able to perform their analytics on a specific version of the graph not affected by concurrent new updates on the graph—provides additional difficulties as well.
There are several approaches for updating graphs. One approach is for a graph processing engine could create a new version of a graph by incorporating changes as a new set of data structures independent from the data structures of the previous graph version. By proceeding this way, it is possible to ensure the same analytical performance by leveraging read-only, fixed graph indices, such as a compressed-sparse-row (CSR) representation. However, with this approach, creating a snapshot requires a lot of resources (memory or disk) due to the full copy of data necessary and will require a lot of time to complete again due to the amount of data that has to be copied, even if this update includes the addition or deletion of a single edge.
Another approach is for a graph processing system to use a single graph index and a single set of graph storage units, in which modifications would be applied concurrently and on the same set of graph storage units (referred to as “in-place updates”). Implementations would rely on non-contiguous memory allocations for neighbor lists to be able to add/remove edges and associated properties which can hurt analytical performance or require larger memory consumption. However, with this approach, there is no snapshot isolation, and the semantics of graph analytics, such as the Pagerank algorithm or shortest-path-finding, often become meaningless and unusable.
Yet another approach is to use a graph data structure, as described above, and to add versioning information in the data-segments used for storing vertex and edge data. To be able to support multiple users manipulating different versions of the graph concurrently, the data-segments should provide the ability to get access to a previous version of that same data-segment. Due to the necessity of maintaining versioning information, and the concurrent aspect of the data structure, it can require more memory to represent the graph and also degrade the analytical performance due to the required traversals to either find the correct version of the data, or to establish what it the data at a specific version from partial representations.
Therefore, there is a need for an approach to provide fast graph updates while maintaining analytical performance.
The example embodiment(s) of the present invention are illustrated by way of example, and not in way by limitation, in the figures of the accompanying drawings and in which like reference numerals refer to similar elements and in which:
In the following description, for the purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the present invention. It will be apparent, however, that the present invention may be practiced without these specific details. In other instances, well-known structures and devices are shown in block diagram form in order to avoid unnecessarily obscuring the present invention.
Techniques described herein update in-memory property graphs in a fast manner, while minimizing memory consumption. A graph is represented as delta compressed sparse rows (CSR), in which its data structure stores forward edge offsets that map reverse edges to forward edges, enabling fast traversals of graph edges in forward and reverse directions. To support fast graph updates, delta logs are used to store changes to the graph. In an embodiment, a base version of the graph data structure is initially loaded or created, and subsequent versions of the graph are created from the reference to the initial graph and a delta log data structure that records the changes compared to the base version of the graph.
An application of the techniques results in creation of graph snapshots isolated from previous versions of the graph, on which performance degradation for typical graph analytics tasks (e.g., executing graph algorithms or graph queries) is minimized.
A graph is a mathematical structure used to model relationships between entities. A graph consists of a set of vertices (corresponding to entities) and a set of edges (corresponding to relationships). When data for a specific application has many relevant relationships, the data may be represented by a graph.
Graph processing systems can be split in two classes: graph analytics and graph querying. Graph analytics systems have a goal of extracting information hidden in the relationships between entities, by iteratively traversing relevant subgraphs or the entire graph. Graph querying systems have a different goal of extracting structural information from the data, by matching patterns on the graph topology.
BACKGROUND IN GRAPH PATTERN MATCHING
Graph pattern matching refers to finding subgraphs, in a given directed graph, that are homomorphic to a target pattern.
A property graph data model allows vertices and edges in a graph to have arbitrary properties as key-value pairs.
Conceptually, a relational DBMS may be interpreted in a graph model. For example, all vertices and their properties may be grouped in a vertex table, while all relationships and their properties may be grouped in an edge table. As an example, the graph illustrated in
A heterogeneous in-memory graph, which is also referred to as “partitioned in-memory graph,” includes one or several vertex tables and edge tables. Each of these tables includes vertices or edges of a certain type with specific sets of properties to each table. A single edge table connects edges between source and destination vertices with the constraints that the source vertices all come from a specific source vertex table and/or that the destination vertices all come from a specific destination vertex table.
Vertex Tables. A vertex table contains vertices of a specific type. For example, a vertex table may hold vertices that represent people and have properties such as FirstName, LastName, Address, etc. Users may decide to split vertex tables further, for example, by having one vertex table representing persons born in the month of September, one for persons born in October, etc. In each vertex table, the vertices are stored in a columnar-fashion (e.g., each vertex property being in a separate array).
A vertex key mapping is maintained to associate the user specified key for that vertex to an internal index for that vertex. The index associated with a vertex is a unique numerical identifier, which is referred to as a physical vertex index. Initially, when a table is created, the index is in the range [0,V) where V is the number of vertices during table loading.
In an embodiment, the physical vertex index of valid vertices remains persistent across different snapshots of the graph as long as the vertices are not deleted and can therefore be used as index into properties. Whenever new vertices are added, they may take the place of previously deleted vertex, which is referred to herein as a vertex compensation. A bit array indicates, for each physical vertex index, if the corresponding vertex is deleted in the current snapshot or not. In an embodiment, one such bit array is created per snapshot. Having such physical vertex indices stable across snapshots makes it possible to minimize disruptive changes for the edges.
Edge Tables. An edge table contains edges that are between some source vertices of a specific source vertex table and some destination vertices of a specific destination table. For example, an edge table may hold edges that represent financial transactions between bank accounts and have properties such as Amount, Currency, etc. An edge table has two special columns: a source vertex column (e.g., Source Vertex Id column in
A graph may be represented by compressed sparse rows (CSR). In a CSR index, edges are represented with arrays: a begin array and a node index array. The begin array lists, for each source vertex physical index, the start index of an “source vertex” edge list of that source vertex in the node index array. The node index array stores, for each edge index, the physical vertex index of the destination vertex. Edges are grouped by source vertex physical index. Additionally, they are sorted based on the physical index of the destination vertices. The contiguous segment of destination vertices belonging to the same source vertex is referred to as an edge list. The position of the edge in the node index array to be the edge index is considered. Grouping edges by source vertex into contiguous edge lists allows for efficient traversal of all outgoing edges of a given vertex. The position of the edge in the node index array is referred to as edge index.
In addition to this “forward” or “direct” CSR that represents the directed edges from source vertex to destination vertex tables, a “reverse” CSR may be generated. The reverse CSR represents the same edges as the forward CSR but in reverse direction. Analogous to the forward CSR, edges are grouped into contiguous edge lists based on their destination vertex. The reverse CSR ensures efficient traversal of incoming edges given a destination vertex. In an embodiment, edge properties are stored according to the forward CSR and not duplicated in the reverse directions. Therefore, edge properties can directly be accessed via forward edge indices.
Since edges are ordered in a different way in the reverse CSR representation, an auxiliary data structure translates reverse edge indices to the edge indices of the forward CSR. In this manner, it is possible to access edge properties when iterating over the reverse CSR representation.
Since edge properties are only stored along the forward direction, it is necessary to be able to determine to what forward edge a reverse edge corresponds to, e.g. to be able to access edge properties when traversing edges from the reverse direction. As described above, an auxiliary data structure (eRev2Idx) may be used to associate or map each reverse edge index with its forward edge index. A reverse edge index would be translated to a forward edge index according to this array and then used to access edge properties. Table 1 illustrate pseudo code of using absolute indices to access edge properties.
With such a mapping, edge insertions or deletions in the forward direction may provoke large disruptions. For example, if an edge is added to the first vertex index, the entire content of eRev2Idx must be incremented by 1, as further described below.
In an embodiment, rather than storing the eRev2Idx mapping, forward edge offsets are stored in an auxiliary data structure (eRevOffset) and the actual forward edge index (for example, when an edge property has to be accessed) is computed whenever needed at run-time. Table 2 illustrates pseudo code of using offset to access edge property.
By using offsets instead of absolute indices, edge additions or deletions become less disruptive: the begin array is modified as part of updating the forward CSR, and the eRevOffset array is modified in much fewer places. The places where eRevOffset has to be modified due to the addition or deletion of edges are referred herein to as damages.
An additional advantage of the eRevOffset array is that it stores small values that can be efficiently compressed, for example using a variant encoding, or that it uses a smaller datatype than would be necessary for the eRev2Idx array.
Since edge lists are kept sorted in the forward and reverse CSR, an edge insertion or removal may happen at any place in the forward edge list. The edges after that insertion/deletion location have therefore a different edge offset by the end of the graph update (except if another edge deletion or insertion compensates that change of offset overall). This change of edge offset must be reflected in the eRevOffset array.
As illustrated in
From a mathematical standpoint, an edge insertion provokes in the worst case the total modification of the eRev2Idx array which is an 0(E) operation, where E is the number of edges, while an edge insertion can only provoke in the worst case as many modifications in eRevOffset array as the maximum out-degree of a vertex, 0(Max({out degree(v), for v in V})).
In an embodiment, one or more data structures used in vertex and edge tables are modified to become delta data structures. Delta data structures store information in a base data structure (also referred herein to as a consolidated version of the data structure) and changes in delta logs.
When a delta log becomes too large for a delta data structure (e.g., according to a threshold considering the size of the consolidated version), a consolidation/compaction operation can be triggered, which merges content of the delta log in a new consolidated version of the delta data structure.
Data structures used in vertex and edge tables may be segmented. Segmenting the data structures used in the vertex and edge tables presents many advantages, including localizing the updates to a reduced portion of a vertex or edge table and enabling sharing data at a finer level between graph snapshots. Additionally, “normal” data structures can be used for unmodified segments to reduce overhead for analytical workloads.
In an embodiment, segmentation is used for different data structures. Segmentation schemes may be different for vertex and edge tables.
Vertex Table Segmentation. Each vertex table can receive modifications independently of the other tables and can therefore be segmented independently from the other tables. Inside a vertex table, a simple scheme which segments according to a fixed chosen size may be adopted, or a certain segment size may be selected to guarantee a certain number of segments. All properties associated with the vertex table follow the same segmentation scheme.
Between graph snapshots, it is possible to share data at segment granularity to maximize memory sharing, according to an embodiment.
Edge Table Segmentation. In edge tables, edges are grouped by source vertices for the forward index and according to the destination vertex for the reverse index. Edge tables can be segmented in per source-vertex segments for the forward delta CSR and edge properties, as illustrated in an example diagram 700 of
Segmentation may be based on a fixed number of edges instead of per vertex. However, in some scenarios, this may not be desirable because adding an edge to a specific segment would require remaking segments, as ordered in the array of consolidated lists, to ensure the desired segment size.
Consolidated data segments and logs of each delta data structure can be shared between graphs. If a segment has no modifications at all between one version and the next, both the consolidated data array and the delta logs can be reused. If modifications were performed, the consolidated array can be reused but the delta logs will differ. In an embodiment, to keep track of the number of snapshots that use each base segment (respective log segment), a reference counter may be used at a data segment (respective log segment) scope. When a data segment (respective log segment) is not used anymore (e.g., reference counter going to 0), it is deallocated.
Techniques described herein use specialized data structures. The following discusses their uses cases in vertex and edge tables.
(Segmented) Arrays with Delta Logs. An array with delta logs includes two components:
Changes to the array with delta logs are put into the delta log without modifying the array of consolidated values.
For example, since the delta log (labeled as logs in
In an embodiment, when the delta log becomes too large, according to some threshold considering the size of the array of consolidated values, a consolidation operation is triggered, and content of the delta log is merged in a new consolidated array.
In an embodiment, both the consolidated array and the delta log can also be segmented so as to limit the scope of the consolidation operations to segments. It may be beneficial for graphs with skewed distributions where changes will frequently affect the same “supernodes,” which will be in only a few segments if the segment size is chosen correctly.
Reference counters associated with the segments of the array of consolidated values and of the delta log are used to determine when memory de-allocation is possible (e.g., when the reference counter becomes zero).
(Segmented) List-Arrays with Delta Logs. A list-array is an array in which each cell (indexed by a list index) contains a list of variable size. A list-array with delta logs includes three components:
While the array of consolidated lists can be viewed to contain lists at a base version, the list delta log contains lists that have been modified or added compared to the base version. A list is modified if values in that list are modified, removed, or added. Similar to arrays with delta logs, the consolidated arrays are not modified when a change is added to the delta log.
For example, since the delta lists positions array (labeled as Delta-lists Positions in
For another example, since the delta lists positions does not have an entry for index 3 of the logical array, a list of [3] is returned by referring to the array of consolidated list begins at index [3] (e.g., having value 3) and index [4] (e.g., having value 4) to determine that one (1) value (e.g., 4−3=1) is to be accessed from the array of consolidated lists at index [3].
For yet another example, since the delta lists positions does not have an entry for index 2 of the logical array, a list of [2, 4] is returned by referring to the array of consolidated list begins at index [2] (e.g., having value 1) and index [3] (e.g., having value 3) to determine that two (2) values (e.g., 3−1=2) are to be accessed from the array of consolidated lists starting at index [1].
For yet another example, since the delta lists positions does not have an entry for index 1 of the logical array, no list is returned by referring to the array of consolidated list at index [1] (e.g., having value 1) and index [2] (e.g., having value 1) to determine that no values (e.g., 1−1=0) are to be accessed from the array of consolidated lists.
In an embodiment, when the list delta log becomes too large, according to some threshold considering the size of the array of consolidated lists, a consolidation operation is triggered, and content of the list delta log is merged in a new consolidated list array.
In an embodiment, both the consolidated list array and the list delta log can also be segmented, according to the list index, so as to limit the scope of the consolidation operations to segments. It may be especially beneficial for graphs with skewed distributions where changes will frequently affect the lists of the same “supernodes,” which will be in only a few segments if the segment size is chosen correctly.
(Segmented) Block-Arrays with Delta Logs. A block-array with delta logs is a special array with delta logs that instead of storing a single value in a cell, stores a fixed sized block of data. For example, instead of having a single integer per cell, if the block size is 64, 64 values would be stored per cell. Such arrays are segmented and subject to consolidation like the other arrays.
(Segmented) Dictionary with Delta Logs. A dictionary is a bidirectional mapping that associates to a key a numerical code. The dictionary with delta logs includes two components:
The consolidated mappings of the dictionary can be viewed as the dictionary for a certain base version. The delta mappings contain the changes with respect to the original version.
To get the code associated to a key, the delta dictionary is first probed. If no mapping is present for the required key (not even the invalid code value indicating a deletion), then the consolidated dictionary is probed. Consolidation and segmentation can be used for the delta mappings from keys to codes and codes to keys.
Delta Data Structures used in Vertex Tables. A bit array is used to indicate, for each physical vertex index, if the vertex is valid or deleted. This bit array can be backed by a full array or, if there are few deletions (common case), by a sparse bitset (not allocating any memory for blocks containing only valid vertices).
For vertex tables, each property is backed by dedicated arrays with delta logs. The vertex key mapping, which provides a mapping from user defined vertex keys to internal vertex index, is backed by a dictionary with delta logs.
Some additional caches, such as arrays, caching the in-degree or out-degree of vertices are also backed by arrays with delta logs.
Delta Data Structures used in Edge Tables. For each edge table, each edge property is backed by dedicated list-arrays with delta logs. The node index arrays of the forward and reverse CSRs are also backed by individual list-arrays with delta logs. If present, an edge key mapping providing a mapping from user defined edge keys to internal edge index is backed by a list-array with delta logs.
The begin arrays of the forward and reverse delta CSRs being monotonically increasing, can be encoded using a checkpoint array (a full array) and a difference array (backed block-array with delta logs). By having this encoding, even if the checkpoint array needs to be completely recomputed from one version of the graph to the next if there are edge additions or removals, it is a much smaller array than the full begin array of the normal CSR (e.g., if the block size is 64, it is 64 times smaller). The array of differences can be mostly re-used as is between versions of the graphs as adding or removing edges only change the differences of a given block (localized changes). The changes to the difference array are put in logs. This encoding is leveraged in the update of the begin array, which is further discussed below regarding the update algorithm of edge tables. Table 3 shows a pseudo code of such an encoding.
Applying changes submitted by a user to create a new graph snapshot is performed in several phases.
Pre-processing the changes submitted by the user. Before starting an application of the changes, the changes submitted by the user are validated to check if they are valid or not, using a pre-processing and validation module. Invalid changes, such as removing a non-existing edge, updating a non-existing property, etc., result in either an error being returned or being ignored.
During the validation process, the changes are also converted to a representation that is more suitable for further processing.
Updating vertex tables. Each vertex table is updated independently, given a set of changes provided by the pre-processing and validation module. If there are no changes for a given vertex table, a fast path that only increments the reference counters of all the delta data structures is taken.
If there are changes for a vertex table, they are processed as follows:
Updating edge tables. Each edge table is updated independently, given a set of changes provided by the pre-processing and validation module. If there are no changes for a given edge table and there are no topological changes to the vertex tables it connects (addition or removal of vertices), a fast path that only increments the reference counters of all the delta data structures is taken.
Post-update of vertex tables. If some vertex tables have additional indices such as indices maintaining the in-degree and out-degree of vertices, then those indices are updated for each vertex table for which there were edge tables with topological changes (e.g., added or removed edges).
Compaction. Having large delta logs degrades the performance of analytical workloads because accessing values in the delta log introduces an overhead. To mitigate that, we consolidate the changes of delta-logged (list) segments once the delta-logs reach a predefined threshold into a new delta-logged (list) segment with empty logs.
In an embodiment, the in-memory bi-directional representation for the graph is generated by generating a forward representation of the graph at step 1004 and a reverse representation of the graph at step 1006.
The forward representation generated at step 1004 includes an edge array. An example edge array is the NodeIdx array of
The forward representation generated at step 1004 also includes a begin array. An example begin array is the Begin array of
For another example, the Begin array index 2 is associated with source vertex with ID 2 and holds the NodeIdx index 5 at which a source vertex edge list of the source vertex with ID 2 is stored sequentially within the NodeIdx array. The source vertex edge list of the source vertex with ID 2 includes destination vertex ids of all destination vertices of the source vertex with ID 2, which in this case there is just one destination vertex stored at NodeIdx[5].
The reverse representation generated at step 1006 includes a reverse edge array. An example reverse edge array is the rNodeIdx array of
The reverse representation generated at step 1006 also includes a reverse begin array. An example reverse begin array is the rBegin array of
For another example, the rBegin array index 1 is associated with destination vertex with ID 1 and holds the rNodeIdx index 2 at which a destination vertex edge list of the destination vertex with ID 1 is stored sequentially within the rNodeIdx array. The destination vertex edge list of the destination vertex with ID 1 includes source vertex ids of all source vertices of the destination vertex with ID 1, which in this case there is just one source vertex stored at rNodeIdx[2].
The reverse representation generated at step 1006 also includes an edge offset array. An example edge offset array is the eRevOffset array of
For another example, eRevOffset index 3 corresponds to rNodeIdx index 3 and an edge and a source vertex of rNodeIdx index 3, and holds an offset of 1 to that edge (e.g., the edge from the source vertex with ID 0 to the destination vertex with ID 2) within a source vertex edge list of the source vertex with ID 0. The source vertex edge list of the source vertex with ID 0 begins NodeIdx[0], and the edge in that source vertex edge list is at NodeIdx[1] (e.g., NodeIdx[0+offset of 1]).
The eRevOffset array maps reverse to forward edges that reduces memory need as well as minimizing the number of entries that need to be updated when edges are added or removed to the graph.
The in-memory bi-directional representation for the graph accelerates traversals of the graph when performing graph analytics and/or graph queries.
In an embodiment, the plurality of vertices and the plurality of edges of the graph are stored in a plurality of tables that includes at least two vertex tables and at least one edge table. Each of the at least two vertex tables stores the plurality of vertices of a certain type with specific sets of properties. Each of the at least one edge tables stores the plurality of edges of a certain type with specific sets of properties.
Each of the plurality of tables is associated with a set of data structures for fast graph updates while maintaining the performance during graph analytics and graph queries.
In an embodiment, each property of a vertex table for the graph is associated with an array with delta logs. The array with delta logs comprises a consolidated values array storing values associated with a consolidated version of the vertex table, and a delta log data structure storing changes compared to the consolidated values array. Data structures of the array with delta logs may be segmented according to a fixed size, and one or more segments may be compacted when a consolidation threshold is satisfied.
In an embodiment, each property of an edge table for the graph is associated with a list-array with delta logs. The list-array with delta logs comprises a consolidated lists array, a consolidated list begins array, and a delta log data structure. The consolidated lists array stores lists associated with a consolidated version of the edge table. The consolidated list, begins array stores, for each consolidated list begins index, a start index of a corresponding list in the consolidated lists array. The delta log data structure comprises a delta lists array storing content of modified or newly added lists, and a list positions data structure storing, for each list positions data structure index, holds a delta lists array index and a length of a particular list. Data structures of the list-array with delta logs are segmented in per-vertex segments, and one or more segments are compacted when a consolidation threshold is satisfied.
In an embodiment, the edge array is a logical representation of a list-array with delta logs. Each of the begin array and the reverse begin array is associated with a checkpoint array and a difference array. The difference array is logical representation of a block-array with delta logs. Data structures of the block-array with delta logs are segmented in per-vertex segments, and one or more segments are compacted when a consolidation threshold is satisfied.
In an embodiment, graph changes are pre-processed and validated prior to updating the plurality of tables.
Each vertex table may be updated independently. For each vertex table that contains one or more vertex changes to the graph, if the one or more vertex changes include vertex deletions, a bit array for a corresponding vertex table may be allocated to indicate deleted vertices. If the one or more vertex changes include vertex additions, as many of the vertex additions may be transformed into vertex compensations and new vertex indices may be assigned to any remaining vertex additions that are not transformed. If the one or more vertex changes include vertex property modifications, for each property associated with the vertex property modifications, a new array of delta logs may be created based on a previous array of delta logs, and the vertex property modifications may be applied to a delta log data structure of the new array of delta logs.
Each edge table may be updated independently. For each edge table that contains one or more edge changes to the graph, if the one or more edge changes include topological edge modifications, a new begin array and a new reverse begin array may be created. For each of the new begin array and the new reverse begin array, a number of edges may be determined for each source vertex of the plurality of vertices and for each destination vertex of the plurality of vertices, and a new checkpoint array and a new difference array may be created based on the determination. In addition, the edge array may be updated by merging delta logs of a previous edge array with the topological edge modifications, and the edge offset array may be updated based on the topological edge modifications. If the one or more edge changes include edge property modifications, for each property associated with the edge property modifications, a new delta log data structure may be created based on a previous delta log data structure, and the edge property modifications may be applied to the new delta log data structure.
Techniques described herein use increase the ability of a graph system to handle evolving graphs and their associated workloads by making the graph engine faster at integrating the changes. The techniques also improve the memory consumption when it is required to keep in memory several snapshots of the graph. The techniques also provide speed and memory benefits while maintaining performance during analytical tasks (e.g., querying, graph algorithm execution). The following discusses improvements over prior approaches discussed above.
(Time-) Partitioned graph support. The techniques described herein support partitioned graphs by vertex and edge type, or by temporality. For example, edges representing financial transactions can be partitioned across several edge indices according to their insertion time. Leveraging a (timed-) partitioned graph index makes it possible to limit the work to update the graph to only the current active set (e.g., data corresponding to the current date) and, therefore, provides update speed benefits proportional to the active set size reduction.
Fast update of bidirectional graph indices. The techniques described herein map reverse to forward edges, reducing memory need as well as minimizing the number of entries that need to be updated when edges are added/removed (minimizing damages, and update algorithm using damages). Traversals of edges in forward and reverse direction are accelerated by using separate graph indices for both cases. The indices for both directions are updated using a delta logging approach. The indices for edge traversals are updated in a manner that preserves the sortedness of the initial indices. It makes it possible to apply optimizations in analytic workloads such as common neighbor matching.
Column-level delta-logging. Rather than having a single delta log to track modifications for an entire vertex or edge and its associated properties, specific segmented delta logs are created for each vertex or edge property and the indices associated to them. This saves space in situations where only some properties are frequently modified.
Vertex-centric segmentation. The techniques described herein leverage a segmentation of the data and of the delta logs according to the vertices to make the changes in the graph, which are local and non-disruptive.
Embodiments of the present invention are used in the context of database management systems (DBMSs). Therefore, a description of an example DBMS is provided.
Generally, a server, such as a database server, is a combination of integrated software components and an allocation of computational resources, such as memory, a node, and processes on the node for executing the integrated software components, where the combination of the software and computational resources are dedicated to providing a particular type of function on behalf of clients of the server. A database server governs and facilitates access to a particular database, processing requests by clients to access the database.
A database comprises data and metadata that is stored on a persistent memory mechanism, such as a set of hard disks. Such data and metadata may be stored in a database logically, for example, according to relational and/or object-relational database constructs.
Users interact with a database server of a DBMS by submitting to the database server commands that cause the database server to perform operations on data stored in a database. A user may be one or more applications running on a client computer that interact with a database server. Multiple users may also be referred to herein collectively as a user.
A database command may be in the form of a database statement. For the database server to process the database statements, the database statements must conform to a database language supported by the database server. One non-limiting example of a database language that is supported by many database servers is SQL, including proprietary forms of SQL supported by such database servers as Oracle, (e.g. Oracle Database 11g). SQL data definition language (“DDL”) instructions are issued to a database server to create or configure database objects, such as tables, views, or complex types. Data manipulation language (“DML”) instructions are issued to a DBMS to manage data stored within a database structure. For instance, SELECT, INSERT, UPDATE, and DELETE are common examples of DML instructions found in some SQL implementations. SQL/XML is a common extension of SQL used when manipulating XML data in an object-relational database.
Generally, data is stored in a database in one or more data containers, each container contains records, and the data within each record is organized into one or more fields. In relational database systems, the data containers are typically referred to as tables, the records are referred to as rows, and the fields are referred to as columns. In object-oriented databases, the data containers are typically referred to as object classes, the records are referred to as objects, and the fields are referred to as attributes. Other database architectures may use other terminology. Systems that implement the present invention are not limited to any particular type of data container or database architecture. However, for the purpose of explanation, the examples and the terminology used herein shall be that typically associated with relational or object-relational databases. Thus, the terms “table”, “row” and “column” shall be used herein to refer respectively to the data container, record, and field.
Query Optimization and Execution Plans
Query optimization generates one or more different candidate execution plans for a query, which are evaluated by the query optimizer to determine which execution plan should be used to compute the query.
Execution plans may be represented by a graph of interlinked nodes, each representing an plan operator or row sources. The hierarchy of the graphs (i.e., directed tree) represents the order in which the execution plan operators are performed and how data flows between each of the execution plan operators.
An operator, as the term is used herein, comprises one or more routines or functions that are configured for performing operations on input rows or tuples to generate an output set of rows or tuples. The operations may use interim data structures. Output set of rows or tuples may be used as input rows or tuples for a parent operator.
An operator may be executed by one or more computer processes or threads. Referring to an operator as performing an operation means that a process or thread executing functions or routines of an operator are performing the operation.
A row source performs operations on input rows and generates output rows, which may serve as input to another row source. The output rows may be new rows, and or a version of the input rows that have been transformed by the row source.
A match operator of a path pattern expression performs operations on a set of input matching vertices and generates a set of output matching vertices, which may serve as input to another match operator in the path pattern expression. The match operator performs logic over multiple vertex/edges to generate the set of output matching vertices for a specific hop of a target pattern corresponding to the path pattern expression.
An execution plan operator generates a set of rows (which may be referred to as a table) as output and execution plan operations include, for example, a table scan, an index scan, sort-merge join, nested-loop join, filter, and importantly, a full outer join.
A query optimizer may optimize a query by transforming the query. In general, transforming a query involves rewriting a query into another semantically equivalent query that should produce the same result and that can potentially be executed more efficiently, i.e. one for which a potentially more efficient and less costly execution plan can be generated. Examples of query transformation include view merging, subquery unnesting, predicate move-around and pushdown, common subexpression elimination, outer-to-inner join conversion, materialized view rewrite, and star transformation.
According to one embodiment, the techniques described herein are implemented by one or more special-purpose computing devices. The special-purpose computing devices may be hard-wired to perform the techniques, or may include digital electronic devices such as one or more application-specific integrated circuits (ASICs) or field programmable gate arrays (FPGAs) that are persistently programmed to perform the techniques, or may include one or more general purpose hardware processors programmed to perform the techniques pursuant to program instructions in firmware, memory, other storage, or a combination. Such special-purpose computing devices may also combine custom hard-wired logic, ASICs, or FPGAs with custom programming to accomplish the techniques. The special-purpose computing devices may be desktop computer systems, portable computer systems, handheld devices, networking devices or any other device that incorporates hard-wired and/or program logic to implement the techniques.
For example,
Computer system 1100 also includes a main memory 1106, such as a random access memory (RAM) or other dynamic storage device, coupled to bus 1102 for storing information and instructions to be executed by processor 1104. Main memory 1106 also may be used for storing temporary variables or other intermediate information during execution of instructions to be executed by processor 1104. Such instructions, when stored in non-transitory storage media accessible to processor 1104, render computer system 1100 into a special-purpose machine that is customized to perform the operations specified in the instructions.
Computer system 1100 further includes a read only memory (ROM) 1108 or other static storage device coupled to bus 1102 for storing static information and instructions for processor 1104. A storage device 1110, such as a magnetic disk, optical disk, or solid-state drive is provided and coupled to bus 1102 for storing information and instructions.
Computer system 1100 may be coupled via bus 1102 to a display 1112, such as a cathode ray tube (CRT), for displaying information to a computer user. An input device 1114, including alphanumeric and other keys, is coupled to bus 1102 for communicating information and command selections to processor 1104. Another type of user input device is cursor control 1116, such as a mouse, a trackball, or cursor direction keys for communicating direction information and command selections to processor 1104 and for controlling cursor movement on display 1112. This input device typically has two degrees of freedom in two axes, a first axis (e.g., x) and a second axis (e.g., y), that allows the device to specify positions in a plane.
Computer system 1100 may implement the techniques described herein using customized hard-wired logic, one or more ASICs or FPGAs, firmware and/or program logic which in combination with the computer system causes or programs computer system 1100 to be a special-purpose machine. According to one embodiment, the techniques herein are performed by computer system 1100 in response to processor 1104 executing one or more sequences of one or more instructions contained in main memory 1106. Such instructions may be read into main memory 1106 from another storage medium, such as storage device 1110. Execution of the sequences of instructions contained in main memory 1106 causes processor 1104 to perform the process steps described herein. In alternative embodiments, hard-wired circuitry may be used in place of or in combination with software instructions.
The term “storage media” as used herein refers to any non-transitory media that store data and/or instructions that cause a machine to operate in a specific fashion. Such storage media may comprise non-volatile media and/or volatile media. Non-volatile media includes, for example, optical disks, magnetic disks, or solid-state drives, such as storage device 1110. Volatile media includes dynamic memory, such as main memory 1106. Common forms of storage media include, for example, a floppy disk, a flexible disk, hard disk, solid-state drive, magnetic tape, or any other magnetic data storage medium, a CD-ROM, any other optical data storage medium, any physical medium with patterns of holes, a RAM, a PROM, and EPROM, a FLASH-EPROM, NVRAM, any other memory chip or cartridge.
Storage media is distinct from but may be used in conjunction with transmission media. Transmission media participates in transferring information between storage media. For example, transmission media includes coaxial cables, copper wire and fiber optics, including the wires that comprise bus 1102. Transmission media can also take the form of acoustic or light waves, such as those generated during radio-wave and infra-red data communications.
Various forms of media may be involved in carrying one or more sequences of one or more instructions to processor 1104 for execution. For example, the instructions may initially be carried on a magnetic disk or solid-state drive of a remote computer. The remote computer can load the instructions into its dynamic memory and send the instructions over a telephone line using a modem. A modem local to computer system 1100 can receive the data on the telephone line and use an infra-red transmitter to convert the data to an infra-red signal. An infra-red detector can receive the data carried in the infra-red signal and appropriate circuitry can place the data on bus 1102. Bus 1102 carries the data to main memory 1106, from which processor 1104 retrieves and executes the instructions. The instructions received by main memory 1106 may optionally be stored on storage device 1110 either before or after execution by processor 1104.
Computer system 1100 also includes a communication interface 1118 coupled to bus 1102. Communication interface 1118 provides a two-way data communication coupling to a network link 1120 that is connected to a local network 1122. For example, communication interface 1118 may be an integrated services digital network (ISDN) card, cable modem, satellite modem, or a modem to provide a data communication connection to a corresponding type of telephone line. As another example, communication interface 1118 may be a local area network (LAN) card to provide a data communication connection to a compatible LAN. Wireless links may also be implemented. In any such implementation, communication interface 1118 sends and receives electrical, electromagnetic, or optical signals that carry digital data streams representing various types of information.
Network link 1120 typically provides data communication through one or more networks to other data devices. For example, network link 1120 may provide a connection through local network 1122 to a host computer 1124 or to data equipment operated by an Internet Service Provider (ISP) 1126. ISP 1126 in turn provides data communication services through the worldwide packet data communication network now commonly referred to as the “Internet” 1128. Local network 1122 and Internet 1128 both use electrical, electromagnetic, or optical signals that carry digital data streams. The signals through the various networks and the signals on network link 1120 and through communication interface 1118, which carry the digital data to and from computer system 1100, are example forms of transmission media.
Computer system 1100 can send messages and receive data, including program code, through the network(s), network link 1120 and communication interface 1118. In the Internet example, a server 1130 might transmit a requested code for an application program through Internet 1128, ISP 1126, local network 1122 and communication interface 1118.
The received code may be executed by processor 1104 as it is received, and/or stored in storage device 1110, or other non-volatile storage for later execution.
A computer system process comprises an allotment of hardware processor time, and an allotment of memory (physical and/or virtual), the allotment of memory being for storing instructions executed by the hardware processor, for storing data generated by the hardware processor executing the instructions, and/or for storing the hardware processor state (e.g. content of registers) between allotments of the hardware processor time when the computer system process is not running. Computer system processes run under the control of an operating system, and may run under the control of other programs being executed on the computer system.
In the foregoing specification, embodiments of the invention have been described with reference to numerous specific details that may vary from implementation to implementation. The specification and drawings are, accordingly, to be regarded in an illustrative rather than a restrictive sense. The sole and exclusive indicator of the scope of the invention, and what is intended by the applicants to be the scope of the invention, is the literal and equivalent scope of the set of claims that issue from this application, in the specific form in which such claims issue, including any subsequent correction.
Software system 1200 is provided for directing the operation of computing device 1100. Software system 1200, which may be stored in system memory (RAM) 1106 and on fixed storage (e.g., hard disk or flash memory) 1110, includes a kernel or operating system (OS) 1210.
The OS 1210 manages low-level aspects of computer operation, including managing execution of processes, memory allocation, file input and output (I/O), and device I/O. One or more application programs, represented as 1202A, 1202B, 1202C . . . 1202N, may be “loaded” (e.g., transferred from fixed storage 1110 into memory 1106) for execution by the system 1200. The applications or other software intended for use on device 1200 may also be stored as a set of downloadable computer-executable instructions, for example, for downloading and installation from an Internet location (e.g., a Web server, an app store, or other online service).
Software system 1200 includes a graphical user interface (GUI) 1215, for receiving user commands and data in a graphical (e.g., “point-and-click” or “touch gesture”) fashion. These inputs, in turn, may be acted upon by the system 1200 in accordance with instructions from operating system 1210 and/or application(s) 1202. The GUI 1215 also serves to display the results of operation from the OS 1210 and application(s) 1202, whereupon the user may supply additional inputs or terminate the session (e.g., log off).
OS 1210 can execute directly on the bare hardware 1220 (e.g., processor(s) 1104) of device 1100. Alternatively, a hypervisor or virtual machine monitor (VMM) 1230 may be interposed between the bare hardware 1220 and the OS 1210. In this configuration, VMM 1230 acts as a software “cushion” or virtualization layer between the OS 1210 and the bare hardware 1220 of the device 1100.
VMM 1230 instantiates and runs one or more virtual machine instances (“guest machines”). Each guest machine comprises a “guest” operating system, such as OS 1210, and one or more applications, such as application(s) 1202, designed to execute on the guest operating system. The VMM 1230 presents the guest operating systems with a virtual operating platform and manages the execution of the guest operating systems.
In some instances, the VMM 1230 may allow a guest operating system to run as if it is running on the bare hardware 1220 of device 1100 directly. In these instances, the same version of the guest operating system configured to execute on the bare hardware 1220 directly may also execute on VMM 1230 without modification or reconfiguration. In other words, VMM 1230 may provide full hardware and CPU virtualization to a guest operating system in some instances.
In other instances, a guest operating system may be specially designed or configured to execute on VMM 1230 for efficiency. In these instances, the guest operating system is “aware” that it executes on a virtual machine monitor. In other words, VMM 1230 may provide para-virtualization to a guest operating system in some instances.
The above-described basic computer hardware and software is presented for purpose of illustrating the basic underlying computer components that may be employed for implementing the example embodiment(s). The example embodiment(s), however, are not necessarily limited to any particular computing environment or computing device configuration. Instead, the example embodiment(s) may be implemented in any type of system architecture or processing environment that one skilled in the art, in light of this disclosure, would understand as capable of supporting the features and functions of the example embodiment(s) presented herein.
Although some of the figures described in the foregoing specification include flow diagrams with steps that are shown in an order, the steps may be performed in any order, and are not limited to the order shown in those flowcharts. Additionally, some steps may be optional, may be performed multiple times, and/or may be performed by different components. All steps, operations and functions of a flow diagram that are described herein are intended to indicate operations that are performed using programming in a special-purpose computer or general-purpose computer, in various embodiments. In other words, each flow diagram in this disclosure, in combination with the related text herein, is a guide, plan or specification of all or part of an algorithm for programming a computer to execute the functions that are described. The level of skill in the field associated with this disclosure is known to be high, and therefore the flow diagrams and related text in this disclosure have been prepared to convey information at a level of sufficiency and detail that is normally expected in the field when skilled persons communicate among themselves with respect to programs, algorithms and their implementation.
In the foregoing specification, the example embodiment(s) of the present invention have been described with reference to numerous specific details. However, the details may vary from implementation to implementation according to the requirements of the particular implement at hand. The example embodiment(s) are, accordingly, to be regarded in an illustrative rather than a restrictive sense.