Abstract:
A method and apparatus for distributing data of a table across a parallel data base system having a plurality of interlinked database nodes. The table is partitioned in accordance with a predetermined partitioning arrangement and data of the table is distributed across a subset of the nodes in accordance with the partitioning arrangement. The partitioning arrangement can comprise horizontal or vertical partitioning. The partitioning arrangement can comprise a partitioning map defining the relationship of partitions of the table to said subset of nodes.

Description:
FIELD OF THE INVENTION 
     This invention relates generally to the storing of data in parallel database systems and more particularly to a method of distributing data in a table across a subset of the nodes of the parallel database system. The invention is particularly useful in relational database systems. 
     BACKGROUND OF THE INVENTION 
     Employing static partitioning for data in a shared nothing parallel data processing system, one method of exploiting parallel processing is to partition database tables across the nodes (typically containing one or more processors and associated storage) of the system. This is referred to as &#34;declustering&#34; of the table. If a database table is partitioned across only a subset of the nodes of the system then that table is said to be &#34;partially declustered&#34;. While the concepts of declustering and partial declustering are known, no method previously existed for constructing or supporting partially declustered tables in a statically partitioned parallel database system. 
     Without partial declustering, the information in each table of the parallel database system would need to be spread across the entire parallel database system which could result in significant inefficiency from excess communication overhead as a result of small tables being distributed across a large number of nodes in the parallel database system. This is referred to as &#34;full declustering&#34; and in addition to the above inefficiency does not permit multiple databases to be divided up into groups of nodes that are subsets of the parallel system. It would be desirable in some cases to divide up the parallel database system into a number of groups of nodes, each group being assigned to a particular database with the tables of that particular database being declustered across the particular group of nodes. 
     Without the ability to perform partial declustering in a parallel database system the user may not have the ability to control the performance and manageability of the parallel database system. 
     SUMMARY OF THE INVENTION 
     The invention herein overcomes the problems of the prior art in providing a method of partial declustering for a statically partitioned parallel database system. 
     The invention provides for and in a statically partitioned parallel database system which has a plurality of interlinked database node in which each of the nodes is associated with storage means and processor resources, a method of distributing data of a table across a subset of the nodes using partitioning of the table. Horizontal or vertical partitioning can be used. 
     More particularly, optimization of the parallel database system under the invention can be achieved by selecting the number of nodes for a subset based on the size of the table to be declustered, the capacity of storage resources at each node, the maximum number of partitions of the table, and the nature of operations to be performed on said table, such as performing a sequential scan, an index based scan or relational join operations. 
     Advantageously the method of the invention includes the use of a partitioning map which is generated to define the mapping of partitions of the table to the nodes in a subset. 
     The method of the invention may include the distribution of data to the nodes in accordance with a partitioning key value, partitioning method, and information stored in the partitioning map. The partitioning key comprises a set of user defined fields for the table. The partitioning key value is the value of a selected set of fields for a particular row of the table. 
     Advantageously the partitioning method may include hash partitioning, range partitioning, or round-robin partitioning, which is applied to the key value to obtain an index value to the partitioning map which defines the location in the partitioning map which provides the node number where the row is to be stored. 
     A useful embodiment of the invention includes one in which each of the nodes is associated with its own storage resources and its own processor or its own set of processors, ie. a shared nothing system. 
     Further aspects of the invention provide a parallel data base system comprising a plurality of interlinked database nodes, each of the nodes having associated storage and processor resources. 
     The database system includes data distribution apparatus for distributing data of a table across the nodes, in which the apparatus includes a partitioner for partitioning the table in accordance with a predetermined partitioning arrangement and distributor for distributing data of said table across a subset of said nodes in accordance with said partitioning arrangement. 
     The partitioning arrangement advantageously may comprise a partitioning map defining the relationship of partitions of the table to the subset of nodes. 
     Preferably, the partitioning map defines the mapping of horizontal partitions of the table to the subset of nodes. 
     Yet another aspect of the invention provides an article of manufacture (a computer program product) comprising a computer useable medium having computer readable program code routine embodied therein for causing a computer system to distribute data of a table across a subset of nodes of a parallel database system. A computer readable program code routine in the article of manufacture comprises a computer readable program code partitioning routine for causing a computer system to partition the table in accordance with a predetermined partitioning arrangement, and computer readable program code for causing a computer system to distribute data of the table across a subset of the nodes in accordance with the partitioning arrangement. 
     The partitioning arrangement preferably comprises a computer readable program code partitioning arrangement routine for causing a computer system to horizontally or vertically partition said table. 
     The partitioning arrangement is preferably a program routine for causing a computer to establish a partitioning map defining the relationship of partitions of the table to the subset of nodes. 
     DESCRIPTION OF THE PREFERRED EMBODIMENT 
     The problem of determining the best storage strategy for the tables in a given parallel database system is known to be a difficult problem (see S. Padmanabhan, &#34;Data Placement in Shared-Nothing Parallel Database Systems&#34;, PhD Thesis, EECS Department, University of Michigan, Ann Arbor, 1992) and several approaches have been taken to solve this problem (see E. Ozkarahan and M. Ouksel, &#34;Dynamic and Order Preserving Data Partitioning for Database Machines&#34;, Proceedings of 1985 VLDB International Conference, 1985; G. Copeland et al, &#34;Data Placement in BUBBA&#34;, Proceedings of 1988 ACM SIGMOD Conference, Chicago, pp. 99-108, June 1988; S. Ghandeharizadeh and D. J. DeWitt, &#34;MAGIC: A Multiattribute Declustering Mechanism for Multiprocessor Database Machines&#34;, IEEE Transactions on Parallel and Distributed Systems, Volume 5, May 1994). 
     Three important aspects of data placement include declustering, assignment and partitioning. Declustering refers to the technique of distributing the rows of a single table across multiple nodes. If the rows are stored across all the nodes of the parallel database system, then the table is said to be &#34;fully declustered&#34;. If the rows are distributed across a subset of nodes, then the table is said to be &#34;partially declustered&#34;. The number of nodes across which a table is declustered is referred to as the &#34;degree of declustering&#34; of the table. The term &#34;table partition&#34; refers to the set of rows of a given table that are all stored at one node of the shared-nothing system (therefore, the number of table partitions equals the degree of clustering). 
     After choosing the degree of declustering, it is important to solve the assignment problem, which is the problem of determining the particular set of nodes on which the table partitions are to be stored. The following issues arise during assignment. Given any two database tables, their assignment may be nonoverlapped, i.e., the two tables do not share any common nodes. Conversely, their assignment may be overlapped, in which case the two tables share at least one node. If both tables share exactly the same set of nodes, then the tables are said to be fully overlapped. Finally, the problem of partitioning refers to the problem of choosing a technique to assign each row of a table to a table partition. Common techniques are, round-robin, hash, and range partitioning. In the last two, a set of columns (attributes) of the table are defined as the partitioning keys and their values in each row are used for hash or range partitioning. 
     While the invention herein is useful in a shared nothing parallel data processing system it is also useful in systems that share some or all resources. In a shared-nothing parallel database system implementing a relational database system, a single database can be stored across several computers (which includes a processor and storage) or nodes that do not share memory or disk storage. A technique called &#34;horizontal partitioning&#34; is used to spread the rows of each table in the database across multiple nodes. The advantage of horizontal partitioning is that one can exploit parallel input/output capability to improve the speed at which data is read from storage units associated with the nodes. The technique used to determine in which node a given row of a table is stored is called the &#34;partitioning strategy&#34;. A number of suitable partitioning strategies exist, eg. key range, round robin, and hash partitioning. For example, in a hash partitioning strategy, a hash function is applied to values in a predetermined set of columns, namely the partitioning key columns, as illustrated in FIG. 5, and the resultant value is used as the node number at which the corresponding row is stored. 
     With horizontal partitioning, there is typically an optimal number of nodes beyond which it is not beneficial to partition data, due to the overheads involved in storing, retrieving and collecting data that is spread across many nodes. Typically, smaller tables should be partitioned across fewer nodes, larger tables should be partitioned against more nodes. Thus, a database user should be allowed to exercise control on the number of nodes on which a table is stored. Also, it is possible that an organization that owns a large parallel computer may administer it in such a way that different databases reside on different sets of nodes. Thus, a shared-nothing parallel database system advantageously should preferably provide mechanisms by which users can control the number of nodes, and the specific nodes, on which the database tables are stored. This is achieved by the present invention and is illustrated in conjunction with the following particular embodiment. 
     While embodiments of the invention are discussed in terms of horizontal partitioning, it will be realized by those skilled in the art referring to this specification, that vertical partitioning can be utilized to spread the columns of a table, or tables across multiple nodes and that the operations and description pertaining to rows can be applied to columns when using vertical partitioning. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     The features of the invention will become more apparent by reference to the following description taken in conjunction with the accompanying drawings, in which: 
     FIG. 1 is a data relationship diagram illustrating the data stored in catalogues (sets of tables describing data in the database) of the database to implement partial declustering of tables in the database system; 
     FIG. 2 is an illustration of the tables contained in the catalogue of the parallel database system, representing information that the system keeps in order to implement partial declustering for user tables; 
     FIGS. 3(a) and 3(b) are an illustration of a series of steps performed when a user creates a partially declustered table in accordance with the invention; 
     FIG. 4 is an illustration of the process by which a user inserts data into a partially declustered table already resident on the parallel database system. 
     FIG. 5 is an illustration of partitioning keys and a partitioning map. 
     FIG. 6 is an illustration of a parallel database system. 
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     The present invention provides a method and apparatus for implementing partial declustering so that users can optimize the performance of database systems. In the particular embodiment discussed below, partial declustering is implemented using horizontal partitioning in the context of hash partitioning of database tables. 
     A parallel database system and the steps for creating a computer program to implement the invention are described herein. 
     The specific implementation herein makes use of nodegroups in order to support partial declustering of hash partition database tables. Nodegroups are subsets each of which is uniquely identified, eg. by a user provided name of the nodes of a parallel database system. Nodegroups are defined within each database, in this example, by a user, although the processing system can provide default nodegroup definitions. 
     At the time of their creation, tables are created within existing nodegroups. As a result, the data in the table is partitioned only across the set of nodes defined in the corresponding nodegroup. In order to facilitate the invention, data definition instructions have been created to allow users to create, drop and alter nodegroup definitions. Relational databases typically use SQL for operation so this embodiment will be discussed with the premise that SQL is used. In the specific embodiment support for nodegroups, new SQL Data Definition Language (DDL) statements have been created. These are discussed below. Referring to FIG. 2, new catalogue tables have also been introduced to store information related to nodegroups in normalized form. These will be discussed in greater detail subsequently in this description. 
     Data Structures 
     FIG. 1 indicates the basic data structures used to implement partial declustering. The figure is basically an entity relationship diagram showing the relationship between various entities (i.e. the items within the boxes). All the entities are specific to each database, except the entities called &#34;nodes&#34;. Databases implemented in the parallel database system have access to the nodes of the parallel database system. The entities that are specific to a database are tables, indexes and two new entities implemented in the present invention, namely &#34;nodegroups&#34; and &#34;partitioning maps&#34;. 
     Nodes 
     In referring to FIG. 6, in parallel database systems, nodes 1, represent a collection of computational resources including usually a processor 6 for processing, main memory 7, disk storage 8, and communication resources 9. The physical processor 6, which has its own main memory 7, and disks 8, and which can communicate with other processors, represents a node. It is also possible to implement multiple nodes in a single physical processor as long as each node manages its own memory disks and communications. In this case, such nodes will typically multiplex the use of a single physical processor or CPU. In the specific implementation herein, the shared-nothing parallel database system uses a known set of nodes across which data from all databases can be stored. Each node is uniquely identified by a node identifier in the embodiment herein. The set of nodes is common to all databases in the system, that is to say, all databases in the system conceptually have the ability to operate on each of the nodes, however, whether they will or not depends on the specific implementation chosen by the database user applying the method of the invention herein. 
     Nodegroups 
     Referring to FIG. 1, the database object called NODEGROUP 2, is a named subset of the set of nodes in a shared-nothing parallel database system described herein. Each nodegroup in a given database is identified by a unique name. As indicated in FIG. 1, the implementation of the invention herein supports a many-to-many (M-N) relationship between nodes and nodegroups. A nodegroup 2, may contain one or more nodes and each node can be a member of zero or more nodegroups. A nodegroup must contain at least one node. FIG. 5 illustrates another nodegroup formed from nodes N1, N2, N3, N4. 
     Partitioning Maps 
     Referring again to FIG. 1, a partitioning map 3 is a data structure associated with a nodegroup 2, which indicates the node on which a given row of a given table is stored. Each partitioning map has a unique partitioning map identification (PMID). As indicated in FIG. 1, each nodegroup 2 is associated with one partitioning map 3 and each partitioning map 3 belongs only to one nodegroup. 
     A partitioning map can be generated by allocating node numbers to the partitions using a round robin allocation scheme to assign node numbers in the partitioning map. For example, in a 20 node system if there are three nodes in a nodegroup eg. nodes 7, 11, 15 and assuming the partition map contains 4K entries then the partitioning map would be generated as 7, 11, 15, 7, 11, 15 . . . which would repeat to fill the entire 4K space. This of course, assumes a uniform distribution of data, allocating an equal number of partitions for each node. Rows of the database are mapped to the nodes in the nodegroup using the partitioning map. 
     The SQL DDL statement to form the nodegroup named MYNODEGROUP would be CREATE NODEGROUP MYNODEGROUP ON NODES (7, 11, 15). 
     Tables 
     Still referring to FIG. 1, a database consists of a set of tables 4. A table 4 in the database is uniquely identified by the creator name and table name, in a typical implementation. Each table is created within a nodegroup. A nodegroup can contain zero or more (N) tables. 
     Indexes 
     A table 4 may have zero or more indexes 5 associated with it. Each index is uniquely identified by the name of the creator and the name of index in this implementation. Other identification methods are useful as well. Each index 5 is associated with a single table 4. Typically the index 5 consists of a fast access structure to access data within the table. This is well known in the art. 
     Physical Data Structures 
     The information about the above data structures, nodegroups, partitioning maps, tables and indexes, are stored in the form of catalogue tables, some of which are illustrated in FIG. 2 as follows: 
     SYSNODEGROUP 10: contains information about nodegroups in the whole processing system eg. the Name of the nodegroup, Definer (the name of the person who defined the nodegroup), Partitioning Map ID for nodegroup. 
     SYSNODEGROUPDEF 11: contains information about the relationship between nodes and nodegroups, i.e. which subset of nodes are in a given nodegroup. 
     SYSPARTITIONMAP 12: contains information about partitioning maps. 
     SYSTABLE 13: contains information about tables, eg. the name of the table, the name of the creator of the table, the name of the nodegroup the table was created in, the partitioning maps ID of the nodegroup. 
     SYSINDEXES 14: contains information about indexes. 
     Procedures for Updating Data Structures 
     Referring to FIGS. 3(a) and 3(b), the following steps are followed in creating a partially declustered table: 
     1. Referring to FIG. 3(a), the following method is used to create a nodegroup on the desired set of nodes. 
     (a) Insert a row of data for the nodegroup into SYSNODEGROUPS. 
     (b) Insert a row of data for the corresponding partitioning map into SYSPARTITIONMAPS. 
     (c) Insert one row of data for each node in the nodegroup into SYSNODEGROUPDEF. 
     2. Referring to FIG. 3(b), the following method is used to create a table in the specified node group: 
     (a) Insert a row in SYSTABLES for this table. 
     (b) In the row corresponding to this table in SYSTABLES, include information, eg. nodegroup name, that links this table to the specified nodegroup. 
     (c) In the row corresponding, store the partitioning key information for the table in SYSTABLES. The partitioning key information is used to decluster the table across the nodes in the nodegroup, as specified in the next section. 
     Inserting Rows into the Table 
     Referring to FIGS. 4 and 5, for each row to be inserted, use the partitioning key value (either directly or after hashing) as an index to the partitioning map data structure of the node group corresponding to this table. The partitioning map indicates the node in which this row is stored. 
     Referring to FIG. 5, the distribution of data of a table across a subset of nodes (nodes 1, 2, 3, 4) in a parallel system is illustrated. 
     In this illustration, A is a column of table 4 and is used as a partitioning key. 
     H(A), (15) is a hash function used to obtain a partition number when applied to the partitioning key value. 
     Partitioning map 3 is an array in which each entry contains the node number of the node in which rows of data that hash to this partition (node) are stored. 
     In this illustration, column B is not used in hashing, the partitioning of data from column B follows that of column A. 
     From a review of FIG. 5 the distribution of data Ai and Bi (i=1 to 6) from table 4 nodes N1, N2, N3 and N4 respectively, is accomplished using partitioning map 3 as may be readily appreciated. 
     A further detailed example of the preferred embodiment of the invention using DDL statements is provided below, in which the aspects of partial declustering, overlapped assignment of database tables into multiple nodegroups, and hash partitioning are illustrated in a parallel database in which several nodegroups are implemented. The following nodegroup DDL statement creates three node groups: 
     CREATE NODEGROUP GROUP --  1 ON NODES (1 TO 32, 40, 45, 48) 
     CREATE NODEGROUP GROUP --  2 ON NODES (1, 3, 33) 
     CREATE NODEGROUP GROUP --  3 ON NODES (1 TO 32, 40, 45, 48) 
     In the above example, GROUP --  1 and GROUP --  3 are two different nodegroups, even though they contain the same set of nodes, (nodes 1 to 32, 40, 45, and 48). Nodegroup GROUP --  2 is partially overlapped with GROUP --  1 and GROUP --  3 (on nodes 1 and 3). 
     Extensions to CREATE TABLE DDL 
     When creating a table, it is advantageous to specify the nodegroup on which the table will be declustered. In addition, it is also advantageous to specify the columns to be used for the partitioning key. 
     The following example illustrates the use of DDL extensions to the CREATE TABLE statement: 
     CREATE TABLE PARTS (Partkey integer, Partno Integer) IN GROUP --  1 PARTITIONING KEY (partkey) USING HASHING 
     CREATE TABLE PARTSUPP (Partkey Integer, Suppkey Integer, PS --  Descp char 50!) IN GROUP --  1 PARTITIONING KEY (Partkey) USING HASHING 
     CREATE TABLE CUSTOMERS (Custkey Integer, C --  Nation char 20!) IN GROUP --  1 PARTITIONING KEY (Custkey) USING HASHING 
     CREATE TABLE SUPPLIERS (Suppkey Integer, S --  Nation char  20!) IN GROUP --  1 PARTITIONING KEY (Suppkey) USING HASHING 
     CREATE TABLE ORDERS (Orderkey Integer, Custkey Integer, Orderdate date) IN GROUP --  1 PARTITIONING KEY (Orderkey) USING HASHING 
     The partitioning key of tables PARTS and PARTSUPP is Partkey. All tables are partitioned across the set of nodes identified by the nodegroup, GROUP --  1. 
     Choosing the Number of Nodes in a Nodegroup 
     When a set of tables is to be created in a nodegroup, the size of the nodegroup should typically be determined by the size of the tables in this set. The nodegroup should contain a minimum number of nodes such that there is sufficient amount of disk storage available to store the data belonging to all the tables. At the same time, the nodegroup should not contain so many nodes that some nodes end up without any data being stored on them. This would be wasteful of system resources. 
     Another consideration is the nature of database operations being performed on the tables. In theory, if a database operation is &#34;perfectly scalable&#34;, then the time taken to perform this operation on a given table (or set of tables) decreases linearly as the number of nodes in the nodegroup increase (this is because each node has less data to process, as the number of nodes increase). However, in practice, due to data transfer, communications, and other synchronization overheads, most operations are not perfectly scalable. As a result, there may be an &#34;optimal&#34; number of nodes beyond which increasing the number of nodes may result in no change in performance or even a decrease in performance. The point at which this can happen must be determined on a case by case basis, based on the hardware capabilities of each node, the nature of the database operation, and the amount of data involved. 
     The database query optimizer present in most database systems can be used to assist in this determination as will be appreciated by those skilled in the art. 
     The absolute maximum for the number of nodes in a nodegroup is, of course, determined by the total number of nodes in the system. 
     Nodegroup example: 
     Suppose we have a database consisting of 3 tables: 
     
         ______________________________________Table A       500,000 rows       50 GBytesTable B       50,000 rows        10 GBytesTable C       100 rows           10 Kbytes______________________________________ 
    
     Suppose we have a system with 64 nodes and a little over 10 Gbytes of database disk storage per node. 
     A minimum of (50+10+0.00001) GBytes / (10 Gbytes/node)=6 nodes is needed to store all the data. 
     Suppose that the typical database operations being performed on these tables are searching of tables A and B and joining of tables A, B, and C. Since the search and join operations in this case are scalable operations, we can increase the number of nodes beyond 6 and obtain a performance improvement for the operations performed on Tables A and B. However, Table C is very small in size and 6 nodes is already too many for that table (assuming a disk page size of 4 Kbytes, the entire Table C can fit on 2.5 pages for which a single node is sufficient). Also, suppose that the optimal number of nodes for performing searching and joins of tables A and B is less than 64, say 40. Then these tables should be created in a nodegroup containing 40 out of the 64 nodes. 
     Thus, for the above database example, we would create two nodegroups, one with 40 nodes and another with 1 node (could be one of the 40 or not). Tables A and B would be created in the 40-node nodegroup and Table C would be created in the 1-node nodegroup. 
     As will be well recognized by those skilled in the art to which this invention pertains, the invention may be practised in computer systems and in computer programs for the operation of computer systems.