Methods and apparatus for processing a database query
In a first aspect, a method is provided that includes the steps of (1) pre-computing a query result for each of a plurality of whole segments of data included in a database; (2) receiving a query specifying a defined range of data in the database; (3) determining if any of the whole segments are within the defined range; (4) performing the query on any partial segments of data within the defined range; and (5) determining the result of the query based on the pre-computed query results for any whole segments determined to be within the defined range and the result of the query on any partial segments within the defined range. Numerous other aspects are provided.
1 . A method, comprising:
pre-computing a query result for each of a plurality of whole segments of data included in a database;
receiving a query specifying a defined range of data in the database;
determining if any of the whole segments are within the defined range;
performing the query on any partial segments of data within the defined range; and
determining the result of the query based on the pre-computed query results for any whole segments determined to be within the defined range and the result of the query on any partial segments within the defined range.
2 . The method of claim 1 wherein determining the result of the query based on the pre-computed query results for any whole segments determined to be within the defined range and the result of the query on any partial segments within the defined range includes determining the result of the query by retrieving the pre-computed query results and determining the result of the query on any partial segments of data within the defined range.
3 . The method of claim 1 further comprising:
storing the pre-computed query results in the database; and
removing pre-computed query results performed on a date range of data older than a specified age from the database.
4 . The method of claim 1 wherein data in the database is grouped into one or more whole segments and partial segments based on a date associated with the data.
5 . The method of claim 1 wherein pre-computing the query result for each of a plurality of whole segments of data included in a database includes pre-computing the query result for each of a plurality of whole segments of data included in a database in response to receiving the query specifying the defined range of data in the database.
6 . A method of processing a database query for information, comprising:
receiving a request to perform a query on a first portion of data in a database;
determining the result of the query on the first portion of the database is based on at least one pre-computed result, wherein the pre-computed result is a result of the query on a second portion of data in the database that is included in the first portion;
performing the query on a third portion of data in the database, wherein the third portion is a portion of the first portion other than the second portion; and
computing the result of the query on the first portion based on the pre-computed result and the result of the query on the third portion.
7 . The method of claim 6 wherein computing the result of the query on the first portion based on the pre-computed result and the result of the query on the third portion includes merging the pre-computed result and the result of the query on the third portion of data.
8 . The method of claim 6 wherein the second portion of data is larger than the third portion of data.
9 . The method of claim 6 wherein computing the result of the query on the first portion based on the pre-computed result and the result of the query on the third portion includes computing the result of the query on the first portion by retrieving the pre-computed result and computing the result of the query on the third portion.
10 . The method of claim 6 further comprising:
storing the pre computed query results in the database; and
removing pre-computed query results performed on a date range of data older than a specified age from the database.
11 . The method of claim 6 wherein the data in the database is grouped into the first, second and third portion of data based on a date associated with the data.
12 . The method of claim 11 wherein at least one of a day, month and year is associated with the second portion of data.
13 . The method of claim 6 wherein the pre-computed result is computed in response to receiving the request to perform a query on the first portion of data in the database.
14 . The method of claim 6 further comprising:
monitoring the pre-computed result; and
determining whether to continue to store the pre-computed result based on the monitoring.
15 . An apparatus, comprising:
a database for storing data;
a processor coupled to the database and adapted to execute code adapted to:
pre-compute a query result for each of a plurality of whole segments of data included in the database;
receive a query specifying a defined range of data in the database;
determine if any of the whole segments are within the defined range;
perform the query on any partial segments of data within the defined range; and
determine the result of the query based on the pre-computed query results for any whole segments determined to be within the defined range and the result of the query on any partial segments within the defined range.
16 . The apparatus of claim 15 wherein the code is further adapted to determine the result of the query by retrieving the pre-computed query results and determining the result of the query on any partial segments of data within the defined range.
17 . The apparatus of claim 15 wherein the code is further adapted to:
store the pre-computed query results in the database; and
remove pre-computed query results performed on a date range of data older than a specified age from the database.
18 . The apparatus of claim 15 wherein data in the database is grouped into one or more whole segments and partial segments based on a date associated with the data.
19 . The apparatus of claim 15 wherein the code is further adapted to pre-compute a query result for each of a plurality of whole segments of data included in a database in response to receiving the query specifying the defined range of data in the database.
20 . An apparatus for processing a database query, comprising:
a database for storing data;
a processor coupled to the database and adapted to execute code adapted to:
receive a request to perform a query on a first portion of data in the database;
determine the result of the query on the first portion of the database is based on a pre-computed result, wherein the pre-computed result is a result of the query on a second portion of data in the database that is included in the first portion;
perform the query on a third portion of data in the database, wherein the third portion is a portion of the first portion other than the second portion; and
compute the result of the query on the first portion based on the pre-computed result and the result of the query on the third portion.
21 . The apparatus of claim 20 wherein the code is further adapted to merge the pre-computed result and the result of the query on the third portion of data.
22 . The apparatus of claim 20 wherein the second portion of data is larger than the third portion of data.
23 . The apparatus of claim 20 wherein the code is further adapted to compute the result of the query on the first portion by retrieving the pre-computed result and computing the result of the query on the third portion.
24 . The apparatus of claim 20 wherein the code is further adapted to:
store the pre-computed query results in the database; and
remove pre-computed query results performed on a date range of data older than a specified age from the database.
25 . The apparatus of claim 20 wherein the data in the database is grouped into the first, second and third portion of data based on a date associated with the data.
26 . The apparatus of claim 25 wherein at least one of a day, month and year is associated with the second portion of data.
27 . The apparatus of claim 20 wherein the code is further adapted to compute the pre-computed result in response to the request to perform a query on the first portion of data in the database.
28 . The apparatus of claim 20 wherein the code is further adapted to:
monitor the pre-computed result; and
determine whether to continue to store the pre-computed result based on the monitoring.
29 . A computer program product, comprising:
a medium readable by a computer, the computer readable medium having computer program code adapted to:
pre-compute a query result for each of a plurality of whole segments of data included in a database;
receive a query specifying a defined range of data in the database;
determine if any of the whole segments are within the defined range;
perform the query on any partial segments of data within the defined range; and
determine the result of the query based on the pre-computed query results for any whole segments determined to be within the defined range and the result of the query on any partial segments within the defined range.
30 . The computer program product of claim 29 wherein the computer program code is further adapted to determine the result of the query by retrieving the pre-computed query results and determining the result of the query on any partial segments of data within the defined range.
31 . The computer program product of claim 29 wherein the computer program code is further adapted to:
store the pre-computed query results in the database; and
remove pre-computed query results performed on a date range of data older than a specified age from the database.
32 . The computer program product of claim 29 wherein data in the database is grouped into one or more whole segments and partial segments based on a date associated with the data.
33 . The computer program product of claim 29 wherein the computer program code is further adapted to compute the pre-computed query result in response to receiving the query specifying the defined range of data in the database.
34 . A computer program product, comprising:
a medium readable by a computer, the computer readable medium having computer program code adapted to:
receive a request to perform a query on a first portion of data in a database;
determine the result of the query on the first portion of the database is based on a pre-computed result, wherein the pre-computed result is a result of the query on a second portion of data in the database that is included in the first portion;
perform the query on a third portion of data in the database, wherein the third portion is a portion of the first portion other than the second portion; and
compute the result of the query on the first portion based on the pre-computed result and the result of the query on the third portion.
35 . The computer program product of claim 34 wherein the computer program code is further adapted to merge the pre-computed result and the result of the query on the third portion of data.
36 . The computer program product of claim 34 wherein the second portion of data is larger than the third portion of data.
37 . The computer program product of claim 34 wherein the computer program code is further adapted to compute the result of the query on the first portion by retrieving the pre-computed result and computing the result of the query on the third portion.
38 . The computer program product of claim 34 wherein the computer program code is further adapted to:
store the pre-computed query results in the database; and
remove pre-computed query results performed on a date range of data older than a specified age from the database.
39 . The computer program product of claim 34 wherein the data in the database is grouped into the first, second and third portion of data based on a date associated with the data.
40 . The computer program product of claim 39 wherein at least one of a day, month and year is associated with the second portion of data.
41 . The computer program product of claim 39 wherein the computer program code is further adapted to compute the pre-computed result in response to receiving the request to perform a query on the first portion of data in the database.
42 . The computer program product of claim 39 wherein the computer program code is further adapted to:
monitor the pre-computed result; and
determine whether to continue to store the pre-computed result based on the monitoring.