This invention relates generally to database query optimization, and more generally to optimization of queries for databases having compressed data.
In order to conserve resources and processing time, many databases are compressed at the storage level using, for example, run-length encoding (RLE) compression or other compression techniques. Compression conserves storage space and reduces the number of read requests. However, queries conventionally decompress compressed stored data and operate on uncompressed data. Thus, in order to execute a query on compressed databases, the data must be first decompressed and the query executed multiple times on decompressed data that may be the same. The multiple intermediate results must then be aggregated to obtain an answer. This is inefficient, and results in substantial and costly processing and long overall response times.
It is desirable to provide systems and methods that address these and other known problems of executing queries on compressed data by minimizing computation costs and reducing query response time, and it is to these ends that the invention is directed.
The invention is particularly well adapted for use with distributed database systems which compresses data at the storage level using RLE-based compression and structured query language (SQL) queries, and will be described in that environment. It will become apparent, however, that this is illustrative of only one utility of the invention and that the invention may be employed with other databases, with other types of compression, and with other query languages.
As will be described, the invention affords optimization of queries on databases employing RLE-based compression at the storage level. It provides a framework to exploit RLE compression during query optimization to optimize the queries to minimize computation costs and reduce overall response time. Optimization processes in accordance with embodiments of the invention identify logical query plans, or portions thereof, that bind to certain predetermined patterns and include certain predetermined query operators and/or aggregation operations involving RLE-compressed relations to which logical transformations may be applied that rearrange the query plan and/or use different query operators to produce an optimized logically equivalent plan. The logical query plans are then transformed into the optimized logically equivalent plans. The transformed plans enable optimized queries to operate directly on compressed data and produce correct results without first having to decompress the data. This minimizes computation costs and reduces overall response time by avoiding the necessity of performing multiple query computations on uncompressed data that is the same.
A logical query plan comprises a tree of query language operators that correspond to relational operations such as GET, COMPRESS, DECOMPRESS, JOIN, GROUPBY, and others. The output of each operator is a relation, and each operator produces a set of output columns. For instance, a GET operator corresponds to reading a relation from a storage device and presenting the data in tabular form. This operator has no children. The JOIN operator has two children which correspond to its inputs. It possesses a qualification expression that corresponds to the join condition between two relations. A GROUPBY operator has one child as an input and has a set of grouping columns that should be logically grouped to compute the output relation. The output of the GROUPBY operator may be associated with aggregate functions such as SUM, MIN and COUNT. A COMPRESS operator has one child, and transforms an uncompressed relation to a compressed one. A DECOMPRESS operator performs the reverse function by transforming a compressed relation into an uncompressed one. For example, a stream of numbers <5,5,6,6,6,6,1,1> may be RLE compressed to the form <(5,2),(6,4),(1,2)> where second number represents frequency of occurrence of the first element (number). The COMPRESS operation goes from a stream of objects to RLE-compressed form, whereas the DECOMPRESS operation goes in the opposite direction.
The logical query plan of
A transformation takes an input query plan and produces a logically equivalent query plan. Every transformation has a precondition that must be satisfied for the transformation to be applicable. The precondition is typically expressed as a pattern tree. If there's a binding (matching) of the input plan to the pattern tree, then the transformation is applicable.
The invention affords patterns and transformations that enable input query plans, or portions thereof, that bind to certain patterns and which operate on uncompressed data to be transformed so that their transformations operate directly on compressed data to produce the correct answers. While pattern binding and transformations are generally known, they have not previously been applied to compressed data. Known query optimization techniques that are applicable to queries for uncompressed data are very difficult to apply to optimize queries that can be used for compressed data and produce correct answers. The invention identifies those query plans that can be transformed to operate correctly on compressed data by matching the structures and semantics of queries to certain predetermined patterns. The invention then transforms the query plans (and queries) accordingly. Transformations in accordance with the invention take as an input a query plan such as illustrated in
The foregoing pattern binding and transformation process of the invention may be applied repeatedly to different portions of a more complex query plan to optimize those portions for compressed data and to produce a new overall query plan that is less costly computationally and that has an improved response time.
While the foregoing description has been with reference to particular embodiments of the invention, it will be appreciated by those skilled in the art that modifications to these embodiments may be made without departing from the principles and spirit the invention, the scope of which is defined by the appended claims.
This application is a continuation of and claims priority to U.S. application Ser. No. 15/250,316, filed on Aug. 29, 2016 (now U.S. Pat. No. 9,652,501), which is a continuation of U.S. application Ser. No. 14/923,228, filed on Oct. 26, 2015 (now U.S. Pat. No. 9,430,524), which is a continuation of U.S. application Ser. No. 13/248,536, filed on Sep. 29, 2011 (now U.S. Pat. No. 9,171,041). The entire disclosures of each of the prior applications are considered part of and are incorporated by reference in the disclosure of this application.
Number | Name | Date | Kind |
---|---|---|---|
6760724 | Chakrabarti et al. | Jul 2004 | B1 |
7167853 | Zaharioudakis et al. | Jan 2007 | B2 |
7773815 | Shen et al. | Aug 2010 | B2 |
8126870 | Chowduri et al. | Feb 2012 | B2 |
8171031 | Tankovich et al. | May 2012 | B2 |
8356027 | Jaecksch et al. | Jan 2013 | B2 |
8671091 | Cherniack | Mar 2014 | B2 |
8688683 | Simon | Apr 2014 | B2 |
9171041 | Narayanan | Oct 2015 | B1 |
9430524 | Narayanan | Aug 2016 | B1 |
9652501 | Narayanan | May 2017 | B1 |
20040034616 | Witkowski et al. | Feb 2004 | A1 |
20050192943 | Siddiqui et al. | Sep 2005 | A1 |
20080071818 | Apanowicz et al. | Mar 2008 | A1 |
20090006399 | Raman | Jan 2009 | A1 |
20100088309 | Petculescu | Apr 2010 | A1 |
20100088315 | Netz | Apr 2010 | A1 |
20010131199 | Simon et al. | Jun 2011 | |
20110208703 | Fisher | Aug 2011 | A1 |
20110302226 | Abadi | Dec 2011 | A1 |
20110307471 | Sheinin | Dec 2011 | A1 |
20110307521 | Slezak et al. | Dec 2011 | A1 |
20120054225 | Marwah et al. | Mar 2012 | A1 |
20120054236 | Branscome et al. | Mar 2012 | A1 |
20120173517 | Lang et al. | Jul 2012 | A1 |
20150088857 | Lee | Mar 2015 | A1 |
Number | Date | Country | |
---|---|---|---|
Parent | 15250316 | Aug 2016 | US |
Child | 15595506 | US | |
Parent | 14923228 | Oct 2015 | US |
Child | 15250316 | US | |
Parent | 13248536 | Sep 2011 | US |
Child | 14923228 | US |