Processing a database table
AssigneeInternational Business Machines Corporation
InventorsKai Feng Cui, Shuo Li, Xin Ying Yang
Life of this patent
Estimating the term…
Abstract
Processing a database table comprises receiving a multi-dimensional processing instruction for processing at least two columns of the database table, wherein the two columns comprise a selection column and a sort column, wherein the multi-dimensional processing instruction is for selecting a plurality of candidate rows by sorting based on the selection column and the sort column. An index takes the selection column as master column and the sort column as slave column. Nodes in the index are selected according to the selection column. Each of the selected nodes is associated with a respective slave column value sequence. A merge sort is performed on each of the slave column value sequences to obtain a sort result for the candidate rows.
Claims12
A method of processing a database table, the method comprising:
- receiving a multi-dimensional processing instruction for processing at least two columns of the database table, wherein one of the two columns is a selection column and the other is a sort column, wherein the multi-dimensional processing instruction is for selecting candidate rows of the table based on the selection column and sorting the selected candidate rows based on the sort column, each row of the table having a value in the selection column and a value in the sort column;
- selecting candidate rows of the table responsive to the candidate rows being indicated for selection by the multi-dimensional processing instruction, where the selecting is performed using an index having a single node for each value that occurs in the selection column, so that even when a value occurs in more than one row of the selection column, the index has as many nodes as there are rows in the table having unique values in the selection column, where each node of the index includes each sort column value for each respective row in the table having the node's selection column value, so that each node of the index has as many sort column values as there are rows in the table having the node's selection column value, where the nodes of the index are configured such that when a node has more than one sort column value, the sort column values in the node are set are in a predetermined sort column value sequence;
- and
- sorting the selected candidate rows according to their sort column values by using the sort column values of the nodes of the index corresponding to the selected candidate rows that were selected responsive to the multi-dimensional processing instruction, where the nodes that correspond to the selected candidate rows are used, including the sort column values of the nodes that correspond to the selected candidate rows, to perform merge sort for obtaining a sort result of the selected candidate rows without performing a sort directly on the sort column values directly from the table,
- wherein sorting the selected candidate rows comprises:
- acquiring the number of sort column value sequences for the selected candidate rows;
- and
- performing the merge sort on each of the sort column value sequences when the number of the sort column value sequences is lower than a merge threshold.
A system of processing a database table, comprising:
- a processor;
- and
- computer readable storage media having instructions stored thereon for execution by the processor, wherein the instructions executed by the processor cause the processor to perform operations comprising:
- receiving a multi-dimensional processing instruction for processing at least two columns of the database table, wherein the two columns comprise a selection column and a sort column, wherein the multi-dimensional processing instruction is for selecting candidate rows based on the selection column and sorting the selected candidate rows based on the sort column, each row of the table having a value in the selection column and a value in the sort column;
- selecting candidate rows of the table responsive to the candidate rows being indicated for selection by the multi-dimensional processing instruction, where the selecting is performed using an index having a single node for each value that occurs in the selection column, so that even when a value occurs in more than one row of the selection column, the index has as many nodes as there are rows in the table having unique values in the selection column, where each node of the index includes each sort column value for each respective row in the table having the node's selection column value, so that each node of the index has as many sort column values as there are rows in the table having the node's selection column value, where the nodes of the index are configured such that when a node has more than one sort column value, the sort column values in the node are set out in a predetermined sort column value sequence;
- and
- sorting the selected candidate rows according to their sort column values by using the sort column values of the nodes of the index corresponding to the selected candidate rows that were selected responsive to the multi-dimensional processing instruction, where the nodes that correspond to the selected candidate rows are used, including the sort column values of the nodes that correspond to the selected candidate rows, to perform merge sort for obtaining a sort result of the selected candidate rows without performing a sort directly on the sort column values directly from the table,
- wherein sorting the selected candidate rows comprises:
- acquiring the number of sort column value sequences for the selected candidate rows;
- and
- performing the merge sort on each of the sort column value sequences when the number of the sort column value sequences is lower than a merge threshold.
A computer program product for processing a database table, the computer program product comprising a non-transitory computer readable storage medium having program instructions embodied therewith, the program instructions executable by a computer to cause the computer to perform operations comprising:
- receiving a multi-dimensional processing instruction for processing at least two columns of the database table, wherein the two columns comprise a selection column and a sort column, wherein the multi-dimensional processing instruction is for selecting candidate rows of the table based on the selection column and sorting the selected candidate rows based on the sort column, each row of the table having a value in the selection column and a value in the sort column;
- selecting candidate rows of the table responsive to the candidate rows being indicated for selection by the multi-dimensional processing instruction, where the selecting is performed using an index having a single node for each value that occurs in the selection column, so that even when a value occurs in more than one row of the selection column, the index has as many nodes as there are rows in the table having unique values in the selection column, where each node of the index includes each sort column value for each respective row in the table having the node's selection column value, so that each node of the index has as many sort column values as there are rows in the table having the node's selection column value, where the nodes of the index are configured such that when a node has more than one sort column value, the sort column values in the node are set out in a predetermined sort column value sequence;
- and
- sorting the selected candidate rows according to their sort column values by using the sort column values of the nodes of the index corresponding to the selected candidate rows that were selected responsive to the multi-dimensional processing instruction, where the nodes that correspond to the selected candidate rows are used, including the sort column values of the nodes that correspond to the selected candidate rows, to perform merge sort for obtaining a sort result of the selected candidate rows without performing a sort directly on the sort column values directly from the table,
- wherein sorting the selected candidate rows comprises:
- acquiring the number of sort column value sequences for the selected candidate rows;
- and
- performing the merge sort on each of the sort column value sequences when the number of the sort column value sequences is lower than a merge threshold.
Dependencies are inferred from the claim text.