The present disclosure relates generally to computer systems and methods. More particularly, the present disclosure relates to optimized query processing systems and methods using aggregates with varying grain sizes for time series data.
Aggregates are commonly used to speed up queries in data warehousing. Whenever time is one of the attributes, it is common to maintain pre-computed aggregates on coarser units of time like hours and days. Depending on the granularity of time used in queries, either hourly or daily aggregates may be used. However, there are cases where it may not be obviously possible to use daily aggregates even though the granularity of time referenced in the query is a day. One example is when daily aggregates are computed each day on GMT boundary. If an incoming query references time in GMT and the granularity of time referenced in query is not finer than a day, it is straightforward to use daily aggregates. However, if the incoming query references time in a different time zone, even though the granularity of incoming query is a day, it is not straightforward to use daily aggregates and one may end up using hourly aggregates. A similar problem results even if the time zone is GMT if the user would want to consider the start of day as 09:00:00 hours rather than 00:00:00 hours.
In an exemplary embodiment, a computer-implemented method for querying aggregates in a database includes maintaining aggregates based on a dimension in the database with at least two grain sizes; receiving a query of the aggregates for a defined range of the dimension; finding a start and an end for a read operation for a larger grain size of the at least two grain sizes of the aggregates for the defined range; reading a first set from the start to the end in the database of the larger grain size of the at least two grain sizes of the aggregates; reading a second set including a smaller grain size of the at least two grain sizes of the aggregates based on the defined range and the start and the end; and adjusting the first set with the second set. The computer-implemented method can further include maintaining the aggregates based on the dimension including time and with one of the at least two grain sizes including a day based on GMT boundaries. The computer-implemented method can further include performing the adjusting by subtracting or adding a portion of the second set at either or both ends of the dimension of the first set. The at least two grain sizes can include a fine grain and a coarse grain; and the computer-implemented method can further include processing the coarse grain aggregates to form the first set; and performing one or more of processing the fine grain aggregates from the second set and excluding the fine grain aggregates from the second set to perform the adjusting. The computer-implemented method can further include receiving the query with the defined range and a time interval; and processing the aggregates based on the time interval. The computer-implemented method can further include performing the reading steps based on an exclusion threshold set to minimize a number of reads.
In an exemplary embodiment, a system includes a network interface, a data store including a database, and a processor, each communicatively coupled therebetween; and memory storing instructions that, when executed, cause the processor to: maintain aggregates based on a dimension in the database with at least two grain sizes; receive a query of the aggregates for a defined range of the dimension; find a start and an end for a read operation for a larger grain size of the at least two grain sizes of the aggregates for the defined range; read a first set from the start to the end in the database of the larger grain size of the at least two grain sizes of the aggregates; read a second set including a smaller grain size of the at least two grain sizes of the aggregates based on the defined range and the start and the end; and adjust the first set with the second set. The memory storing instructions that, when executed, can further cause the processor to: maintain the aggregates based on the dimension including time and with one of the at least two grain sizes including a day based on GMT boundaries. The memory storing instructions that, when executed, can further cause the processor to: perform the adjusting by subtracting or adding a portion of the second set at either or both ends of the dimension of the first set. The at least two grain sizes can include a fine grain and a coarse grain, and wherein the memory storing instructions that, when executed, can further cause the processor to: process the coarse grain aggregates to form the first set; and perform one or more of processing the fine grain aggregates from the second set and excluding the fine grain aggregates from the second set to perform the adjusting. The memory storing instructions that, when executed, can further cause the processor to: receive the query with the defined range and a time interval; and process the aggregates based on the time interval. The memory storing instructions that, when executed, can further cause the processor to: perform the reading steps based on an exclusion threshold set to minimize a number of reads.
In yet another exemplary embodiment, software stored in a non-transitory computer readable medium and including instructions executable by a processor, and in response to such execution causes the processor to perform operations including maintaining aggregates based on a dimension in the database with at least two grain sizes; receiving a query of the aggregates for a defined range of the dimension; finding a start and an end for a read operation for a larger grain size of the at least two grain sizes of the aggregates for the defined range; reading a first set from the start to the end in the database of the larger grain size of the at least two grain sizes of the aggregates; reading a second set including a smaller grain size of the at least two grain sizes of the aggregates based on the defined range and the start and the end; and adjusting the first set with the second set.
The present disclosure is illustrated and described herein with reference to the various drawings, in which like reference numbers are used to denote like system components/method steps, as appropriate, and in which:
In various exemplary embodiments, optimized query processing systems and methods using aggregates with varying grain sizes for time series data are described. The optimized query processing systems and methods improve data processing in large data systems. Specifically, the optimized query processing systems and methods determine a most optimal way of using all the aggregates for a given input query which results in a sequential read operation for coarser grain aggregates. Even if the aggregates are maintained according to a chosen time zone, the optimized query processing systems and methods enable processing queries from different time zones. In the foregoing description, examples deal with time as a dimension for illustration purposes; those of ordinary skill in the art will recognize the optimized query processing systems and methods can be used on other dimensions as well.
Referring to
The optimized query processing systems and methods include procedures to make use of the coarse grain aggregates 14 as much as possible in combination with fine grain aggregates 12 to answer such queries where otherwise only the fine grain aggregates 12 would be used. In this manner, the optimized query processing systems and methods seek to minimize read operations by maximizing use of the coarse grain aggregates 14 as much as possible. Generally, the query 20 is split into three components, namely (1) portion of the range that can be mapped directly into the coarse grain aggregates 14 maintained by the data system 10, (2) portion of the range that precedes (1), and (3) portion of the range that succeeds (1).
Again, there are the two types of aggregates 12, 14, the fine grain aggregate 12 can have a dimension and size of an hour and the coarse grain aggregate 14 can have the dimension and size of a day. The input query 20 request for this example can be a time range from 1 Feb. 2014 07:00 to 3 Feb. 2014 07:00 and the aggregate function is SUMO. Assume the coarse grain aggregate 14 for each day are stored from 00:00 hours, and since the coarse grain aggregate 14 (daily data) starts only from 00:00 hours, it is not possible to use it directly. Here is a breakdown on how the query 20 would be processed.
The Table 1 shows how the input time range is split. Again, the goal is split the usage such that the coarse grain aggregate 14 usage is the largest. Here, the data system 10 reads one day worth of data from coarse grain aggregate 14 as well as reading and adding 17 hours for the first split and 7 hours from the third split using the fine grain aggregates 12.
For further optimization, the data system 10 always wants to read more of the coarse grain aggregate 14 even if the start and the end range of the coarse grain aggregate 14 may be outside the desired range. In
In
Fn(A)=Fn(S−B)=Fn(Fn(S), Fn−1(B))
If there exist such function Fn−1 (inverse of Fn) that the above equation is true, then the data system 10 can use the exclusion optimization for such a function. For example if Fn=SUM( ), then:
Functions such as MIN or MAX cannot use the exclusion optimization. However, normal methods of combining the aggregates (without exclusion) would still work fine for such functions.
Example of Exclusion in Action
When using exclusion for aggregate functions like SUM, the data system 10 needs to subtract the excluded data from the result set. That is, the data system 10 uses the coarse grain aggregate 14 to overlap and the fine grain aggregates 12 for exclusion. In the previous example (1), the data system 10 only used additions. For the first range from 1st February 07:00 to 2nd February 00:00, the data system 10 added 17 hours of data. The usage of the coarse grain aggregate 14 could further be improved by applying subtraction (exclusion) as shown in Table 2 below.
By simply introducing the capability of subtraction, the data system 10 has reduced the amount read from the fine grain aggregates 12 to 14 hours instead of 24 hours. In most cases, introducing subtraction results in reduced number of read operation and increases the utilization of coarser grain aggregates 14.
Using Caching to Improve Reads of Aggregate Data
Let's extend the above examples by doing range queries with intervals as 3 days and the query range as 9 days. The data system 10 has 3 intervals to process. Query start time is 1 Feb. 2014 07:00 and end time is 9 Feb. 2014 07:00, and operations by the data system 10 are shown in Table 3.
In the Table 3, it is shown that data from 3rd February 00:00 to 3rd February 07:00 that was added in the first interval (1st February 07:00 to 3rd February 07:00) can be reused for subtraction in the second interval (3rd February 07:00 to 6th February 07:00). Enabling subtraction also enables efficient utilization of cache data and overall reduction of input/output required from storage layer of the data system 10.
Optimized Query Processing Systems and Methods
Referring to
Time is the most common dimension that can be divided into range and is very popular in event logs and streaming data. Again, in the examples and algorithms described herein, time is used as the dimension since it is very easy to visualize time ranges. Other dimensions are also contemplated.
The grain size of these aggregates could vary from small variation on the value of the dimension to a large variation. For example, time based aggregates could have the aggregate grain size as hour, day or month. An input query with large time span operation can then be processed using combination of these aggregates. For example if the solution contains aggregates of hourly (fine grain) and daily (coarse grain) time span, then an input query of time span of two days could be answered using combination of both the fine and coarse grain aggregates as shown in examples above at Table 1 and Table 2.
Figuring Out the Read Operation Range Boundaries for Time Based Aggregates
By definition and implication of input query range, the start and the end range values of the query cannot be changed. But data read range (used for read operation) can be changed to get the optimal performance. So the challenge is, for a given query range finding the start and the end for the read operation for all the available aggregates. The following describes arriving at equations for finding out read ranges for aggregates of varying granularity to satisfy a query. All units in the equation below are the same as the unit of the finest grain size aggregate. The following terminology is used:
The exThres is the property of the aggregate and the granularity of the exclusion unit should be the granularity of the next finer aggregate. For example, if the aggregate the data system 10 is applying has a time span of day and the immediate finer time span for aggregate is hourly, then exThres should be in terms of hours.
The following equations are used in the optimized query processing method 30:
Choosing the Value of Exclusion Threshold
The exclusion threshold (exThres) determines for what amount of un-alignment in the query range, exclusion should be preferred over normal inclusion (addition) method. By default, for most of the cases the value should be equal to half of the grain size of the aggregate. For example an aggregate with grain size of a day, the exclusion threshold should be half a day but the actual value depends on the next immediate finer grained aggregate. For example, in this case of the next immediate aggregates grain size was hour then the value would be 12 hours or if the next immediate grain size was minute then the value would be 720 minutes. Setting this value to zero would effectively turn off this optimization. When applying aggregate functions that cannot be evaluated with exclusion, this value should be set to zero to disable exclusion.
Algorithm to Find Range Boundaries for all Time Based Aggregates
The optimized query processing method 30 starts setting ST to query start time, ET to query end time, and aggregate Ax to A1 (step 40). The optimized query processing method 30 finds the start and end boundaries for the given boundaries using the above equations; let them be STA and ETA respectively (step 41). The optimized query processing method 30 processes aggregates from STA to ETA using aggregate AX (step 42). The optimized query processing method 30 checks if AX+1=AX (step 43). If not (step 43), the optimized query processing method 30 sets the aggregate AX to aggregate AX+1 (step 44), and the optimized query processing method 30 checks if ST is greater than STA (step 45). If ST is less than or equal to STA (step 45), the optimized query processing method 30 sets ST to STA and ET to ST and performs a recursive call (step 46). If ST is greater than STA (step 45), the optimized query processing method 30 sets ST to ST and ET to STA and performs a recursive call (step 47). Subsequent to the steps 46, 47, the optimized query processing method 30 checks if ET is greater than ETA (step 48).
If ET is less than or equal to ETA (step 48), the optimized query processing method 30 sets ST to ET and ET to ETA and performs a recursive call (step 49). If ET is greater than ETA (step 48), the optimized query processing method 30 sets ST to ETA and ET to ET and performs a recursive call (step 50). After the recursive calls, the optimized query processing method 30 returns to the step 41.
If AX+1=AX (step 43), the optimized query processing method 30 checks if ST is greater than STA (step 51). If ST is less than or equal to STA (step 52), the optimized query processing method 30 processes aggregate from ST to STA using smallest time span aggregate AN (step 52). If ST is greater than STA (step 51), the optimized query processing method 30 applies an exclusion on aggregate from STA to ST using smallest time span aggregate AN (step 53).
The optimized query processing method 30 checks if ET is greater than ETA (step 54). If ET is less than or equal to ETA (step 54), the optimized query processing method 30 applies an exclusion on aggregate from ET to ETA using smallest time span aggregate AN (step 55). If ET is greater than ETA (step 54), the optimized query processing method 30 processes aggregate from ETA to ET using smallest time span aggregate AN (step 56).
The optimized query processing method 32 checks if ST is greater than STA (step 63). If ST is less than or equal to STA (step 63), the optimized query processing method 32 processes aggregate from ST to STA using smaller time span aggregate (step 64). If ST is greater than STA (step 63), the optimized query processing method 32 applies exclusion on aggregate from STA to ST using smaller time span aggregate (step 65).
The optimized query processing method 32 checks if ET is greater than ETA (step 66). If ET is less than or equal to ETA (step 66), the optimized query processing method 32 applies exclusion on aggregate from ET to ETA using smaller time span aggregate (step 67). If T is greater than ETA (step 66), the optimized query processing method 32 processes aggregate from ETA to ET using smaller time span aggregate (step 68).
Processing Queries with Time Interval
So far, the description of herein has been around an entire query range. The methods described herein can be used even when the query range is broken down into intervals. The same procedure is repeated for each interval. The equations above are applied to each interval to determine the break-up of various types of aggregates to be used. The query start time and the query end time in the interval now correspond to interval start time and interval end time respectively. The interval start time of the very first interval is query start time. The interval end time is equals to the interval start time plus the interval period.
Calculating Intervals
The interval end time at the beginning of the algorithm or evaluation is set to 0. Else, it's computed as below
Referring to
Referring to
The processor 102 is a hardware device for executing software instructions. The processor 102 may be any custom made or commercially available processor, a central processing unit (CPU), an auxiliary processor among several processors associated with the server 100, a semiconductor-based microprocessor (in the form of a microchip or chip set), or generally any device for executing software instructions. When the server 100 is in operation, the processor 102 is configured to execute software stored within the memory 110, to communicate data to and from the memory 110, and to generally control operations of the server 100 pursuant to the software instructions. The I/O interfaces 104 may be used to receive user input from and/or for providing system output to one or more devices or components. User input may be provided via, for example, a keyboard, touch pad, and/or a mouse. System output may be provided via a display device and a printer (not shown). I/O interfaces 104 may include, for example, a serial port, a parallel port, a small computer system interface (SCSI), a serial ATA (SATA), a fibre channel, Infiniband, iSCSI, a PCI Express interface (PCI-x), an infrared (IR) interface, a radio frequency (RF) interface, and/or a universal serial bus (USB) interface.
The network interface 106 may be used to enable the server 100 to communicate on a network, such as the Internet, a wide area network (WAN), a local area network (LAN), and the like, etc. The network interface 106 may include, for example, an Ethernet card or adapter (e.g., 10BaseT, Fast Ethernet, Gigabit Ethernet, 10GbE) or a wireless local area network (WLAN) card or adapter (e.g., 802.11a/b/g/n). The network interface 106 may include address, control, and/or data connections to enable appropriate communications on the network. A data store 108 may be used to store data. The data store 108 may include any of volatile memory elements (e.g., random access memory (RAM, such as DRAM, SRAM, SDRAM, and the like)), nonvolatile memory elements (e.g., ROM, hard drive, tape, CDROM, and the like), and combinations thereof. Moreover, the data store 108 may incorporate electronic, magnetic, optical, and/or other types of storage media. In one example, the data store 108 may be located internal to the server 100 such as, for example, an internal hard drive connected to the local interface 112 in the server 100. Additionally in another embodiment, the data store 108 may be located external to the server 100 such as, for example, an external hard drive connected to the I/O interfaces 104 (e.g., SCSI or USB connection). In a further embodiment, the data store 108 may be connected to the server 100 through a network, such as, for example, a network attached file server. The data store 108 can include a database with the fine grain aggregates 12 and the coarse grain aggregates 14.
The memory 110 may include any of volatile memory elements (e.g., random access memory (RAM, such as DRAM, SRAM, SDRAM, etc.)), nonvolatile memory elements (e.g., ROM, hard drive, tape, CDROM, etc.), and combinations thereof. Moreover, the memory 110 may incorporate electronic, magnetic, optical, and/or other types of storage media. Note that the memory 110 may have a distributed architecture, where various components are situated remotely from one another, but can be accessed by the processor 102. The software in memory 110 may include one or more software programs, each of which includes an ordered listing of executable instructions for implementing logical functions. The software in the memory 110 includes a suitable operating system (O/S) 114 and one or more programs 116. The operating system 114 essentially controls the execution of other computer programs, such as the one or more programs 116, and provides scheduling, input-output control, file and data management, memory management, and communication control and related services. The one or more programs 116 may be configured to implement the various processes, algorithms, methods, techniques, etc. described herein.
It will be appreciated that some exemplary embodiments described herein may include one or more generic or specialized processors (“one or more processors”) such as microprocessors, digital signal processors, customized processors, and field programmable gate arrays (FPGAs) and unique stored program instructions (including both software and firmware) that control the one or more processors to implement, in conjunction with certain non-processor circuits, some, most, or all of the functions of the methods and/or systems described herein. Alternatively, some or all functions may be implemented by a state machine that has no stored program instructions, or in one or more application specific integrated circuits (ASICs), in which each function or some combinations of certain of the functions are implemented as custom logic. Of course, a combination of the aforementioned approaches may be used. Moreover, some exemplary embodiments may be implemented as a non-transitory computer-readable storage medium having computer readable code stored thereon for programming a computer, server, appliance, device, etc. each of which may include a processor to perform methods as described and claimed herein. Examples of such computer-readable storage mediums include, but are not limited to, a hard disk, an optical storage device, a magnetic storage device, a ROM (Read Only Memory), a PROM (Programmable Read Only Memory), an EPROM (Erasable Programmable Read Only Memory), an EEPROM (Electrically Erasable Programmable Read Only Memory), Flash memory, and the like. When stored in the non-transitory computer readable medium, software can include instructions executable by a processor that, in response to such execution, cause a processor or any other circuitry to perform a set of operations, steps, methods, processes, algorithms, etc.
Although the present disclosure has been illustrated and described herein with reference to preferred embodiments and specific examples thereof, it will be readily apparent to those of ordinary skill in the art that other embodiments and examples may perform similar functions and/or achieve like results. All such equivalent embodiments and examples are within the spirit and scope of the present disclosure, are contemplated thereby, and are intended to be covered by the following claims.
Number | Name | Date | Kind |
---|---|---|---|
9633076 | Morton | Apr 2017 | B1 |
20090182779 | Johnson | Jul 2009 | A1 |
20100275128 | Ward | Oct 2010 | A1 |
20110179066 | Cardno | Jul 2011 | A1 |
20120124043 | Handy | May 2012 | A1 |
20150370816 | Anand | Dec 2015 | A1 |
Number | Date | Country | |
---|---|---|---|
20160048558 A1 | Feb 2016 | US |