Data management systems maintain data storages. Users may interact with the data management system to access data in the data storages by providing queries to the data management systems. For example, a user may submit queries to the data management system requesting that corresponding data be retrieved and/or presented (e.g., via reports).
Wherever possible, the same reference numbers will be used throughout the drawing(s) and accompanying written description to refer to the same or like parts.
Examples disclosed herein involve directed queries that cause an optimizer to select an execution plan for a query using hints, in examples herein, a query manager generates annotated queries from execution plans selected by an optimizer of a database management system. The annotated queries may include hints to cause the optimizer to select an execution plan corresponding to the hints. In some examples, customized annotated queries may be provided to the query manager via user input to cause the optimizer to generate an execution plan in accordance with hints of the customized annotated queries.
Due to the frequently changing state of a database (e.g., updates, added data, removed data, copied data, etc.), an optimizer of a database management system may adjust execution plans for queries to account for the changing states. In some instances, this may affect speed of processing a query (e.g., retrieval of data may be slower than a previously selected execution plan). Examples herein generate annotated queries to store respective execution plans for corresponding queries. An example query manager may provide the annotated queries to an optimizer instead of a corresponding query to enhance execution timing of the query by reverting back to a previously selected execution plan. This annotated query may be provided because a new execution plan that processes the query is slower than the previously selected execution plan. Thus, by providing the annotated query to the optimizer, the optimizer may revert back to the previously selected execution plan rather than continue to use the slower new execution plan. In examples herein, a query manager may map queries (e.g., using a hash and an index) to corresponding annotated queries such that when a same query is subsequently received, the query manager provides the optimizer with the annotated query (rather than the query),
As used herein, a query is a request for information/data from a database. In examples herein, an optimizer selects execution plans for queries submitted to a database management system. Example optimizers herein may be implemented using any suitable means. It is noted that, in examples herein, an optimizer may or may not select an “optimal” execution plan for queries.
Examples herein involve providing a first query to an optimizer; identifying a first execution plan selected by the optimizer based on the first query; generating an annotated query based on the selected execution plan, the annotated query comprising hints for executing the selected execution plan; and storing the annotated query in a database, the annotated query to cause the optimizer to generate a second execution plan corresponding to the first execution plan based on the hints.
The example user interface 120 facilitates user interaction with database management system 100. For example, the user interface 120 may include input device(s) (e.g., a keyboard, a mouse, a trackball, a microphone, etc.) and output device(s) (e.g., a display, speaker(s), etc.). In examples herein, a user may input queries (e.g, structured query language (SQL) queries) for execution/processing by the execution engine 140. In some examples, a user may input user annotated queries via the user interface 120. For example, the user may provide a query and subsequently provide a user annotated query with instructions to match the query to the user annotated query. Accordingly, when the query is subsequently received from the user interface, the user annotated query is provided to the optimizer 130.
The example optimizer 130 of
In examples herein, the optimizer 130 may receive an annotated query from the query manager. The annotated query may include hints (which may be referred to interchangeably herein as annotations) that instruct the optimizer 130 to select an execution plan according to the hints or cause an execution engine to execute an execution plan according to the hints. The annotated query may correspond to a previously received query or a query stored/managed by the query manager 110. The hints of the annotated query may constrain the optimizer 130 to select an execution plan from a single option (e.g., an execution plan that was previously executed for a query corresponding to the annotated query). Therefore, the optimizer 130 may select a different execution plan to retrieve the same data when the annotated query is received versus when the corresponding query was received. The optimizer 130 selecting the different execution plan for the annotated query may take less time to retrieve the data relative to the optimizer 130 selecting an execution plan for the corresponding query.
The example execution engine 140 executes the execution plan selected by the optimizer 130 to retrieve data requested in the corresponding query or annotated query. The execution engine 140 may then provide the retrieved data back to the user interface 120 for interaction with the user (e.g., display, editing, etc.).
The example query manager 110 of
The example query mapper 210 of
In examples herein, if the query mapper 210 determines that a received query has not been received in the past (i.e., there is no correspond entry in the annotated query database 240), the query mapper 210 may create an entry in the annotated query database 240. The new entry in the annotated query database 240 may maps the query (and/or a hash of the query) to an annotated query. Accordingly, when the received query is subsequently received, the query mapper 210 may refer to the entry in the annotated query database 240 to retrieve an annotated query. If the query mapper 210 determines that the received query has been received in the past (e.g., based on a hash of the query, comparison of the query and a query in the annotated query database 240), the query mapper 210 may retrieve a corresponding annotated query mapped to the received query from the annotated query database 240.
The example optimizer interface 220 facilitates communication with the optimizer 130 of the data management system 100. The example optimizer interface 220 may provide the received query and/or a corresponding annotated query to the optimizer 130 (based on whether the received query was previously received). In examples herein, the optimizer interface 220 may monitor or communicate with the optimizer 130 to identify/determine execution plans selected for queries. For example, if a query was provided to the optimizer 130 (rather than an annotated query), the optimizer interface 220 may monitor the optimizer 130 to identify the selected execution plan for the execution engine 140. The optimizer interface 220 provides the selected execution plan to the annotated query generator 230 to create an annotated query that corresponds to the query.
In examples herein, the annotated query generator 230 generates annotated queries from execution plans selected by the optimizer 130. The annotated query generator 230 may parse the execution plan to identify an order and process of the execution plan. Based on the order and process, the annotated query generator 230 creates an annotated query corresponding to the query along with hints. In examples herein, the hints may include join orders, distribution operation, join types, projection choices, etc. In some examples custom hints may be used to offer flexible execution plans. For example, for a query seeking data from a current month (e.g., “April”), a hint may be included to ignore the month (e.g., “March”) listed in the initial query, and use the current month (e.g., “April”) at the time of providing the annotated query. Accordingly, the hints may be included as annotations within the query itself and identify specific operations that are to be performed in executing the annotated query.
It is reiterated that the annotated query is to cause an optimizer to select an execution plan that returns the same data as an execution plan selected by the optimizer 130 when receiving the corresponding query. However, the execution plans themselves (e.g., order of operation, types of operations, etc.,) may be different from one another. The annotated query generator 230 stores the created annotated query in the entry created when the corresponding query was received.
For illustrative purposes,for the following example query:
SELECT c,name
FROM customer c, item i, purchase p
WHERE c.cid=p.cid AND p.iid=i.iid
AND i.type=‘household’
AND c.age<30
AND Month(p,date)=‘March’; (1)
the annotated query generator 230 create the following based on an execution plan selected by the optimizer 130:
SELECT/*syntactic_join*/c.name
FROM ((purchase p JOIN/*+Jtype(H)*/customer c
WHERE i.type=‘household’
AND cage<30
AND Month(p,date)=‘March’; (2)
In the above examples, the annotated query (2) includes hints that cause an optimizer 130 to select an execution plan that effectively is a same execution plan that was previously selected by the optimizer 130 to process the query (1).
The example annotated query database 240 stores annotated queries in accordance with aspects of this disclosure. In some examples, the annotated query database includes an index that maps a hash of a query (or of a parsed query) to an original query and/or to a corresponding annotated query. For example, an entry or index for a particular query may include a hash of the query, the query itself, and a corresponding annotated query. In some examples, when checking the annotated query database 240 to determine if a query has been previously received (and determine if an annotated query exists in the annotated query database 240), the query mapper 210 may calculate the hash value to use as an index entry to find possible query matches, then compare the received query to any entries having the same hash value. In such examples, the query mapper 210 may then find the same query by parsing and comparing the original query and received query. If the same query is found from the entries with the same hash value, the query mapper may then retrieve the corresponding annotated query from the database to provide to the optimizer 230.
While an example manner of implementing the query manager 110 of
Flowcharts representative of example machine readable instructions for implementing the query manager 110 of
The example process 300 of
At block 330 of
The example process 400 of
At block 430, the query mapper 210 maps the query to the user annotated query in the annotated query database 240. For example, at block 430, the query mapper 210 may calculate a hash of the query, and store the hash, the query, and the annotated query in an entry of the annotated query database 240 and/or an index of the annotated query database 240. After block 430, the example process 400 ends.
The example process 500 of
If, at block 520, the query is in the annotated query database 240 (e.g., based on a comparison of a hash of the query and a hash in the annotated query database 240, based on a comparison of the query and a query in the annotated query database 240), the optimizer interface 220 provides an annotated query corresponding to the query from the annotated query database 240 to the optimizer 130 (block 530). If, at block 520, the query mapper 510 determines that the query is not in the annotated query database 240, the optimizer interface 220 provides the query to the optimizer 230. After blocks 530. 540, the example process 500 ends. After the process 500 ends, the example optimizer 130 may select an execution plan for the execution engine to process the query and/or annotated query.
As mentioned above, the example processes of
The processor platform 600 of the illustrated example of
The processor 612 of the illustrated example includes a local memory 613 (e.g., a cache). The processor 612 of the illustrated example is in communication with a main memory including a volatile memory 614 and a non-volatile memory 616 via a bus 618. The volatile memory 614 may be implemented by Synchronous Dynamic Random Access Memory (SDRAM), Dynamic Random Access Memory (DRAM), RAMBUS Dynamic Random Access Memory (RDRAM) and/or any other type of random access memory device. The non-volatile memory 616 may be implemented by flash memory and/or any other desired type of memory device. Access to the main memory 614, 616 is controlled by a memory controller.
The processor platform 600 of the illustrated example also includes an interface circuit 620. The interface circuit 620 may be implemented by any type of interface standard, such as an Ethernet interface, a universal serial bus (USB), and/or a peripheral component interconnect (PCI) express interface.
In the illustrated example, at least one input device 622 is connected to the interface circuit 620. The input device(s) 622 permit(s) a user to enter data and commands into the processor 612. The input device(s) can be implemented by, for example, an audio sensor, a microphone, a camera (still or video), a keyboard, a button, a mouse, a touchscreen, a track-pad, a trackball, isopoint and/or a voice recognition system.
At least one output device 624 is also connected to the interface circuit 620 of the illustrated example. The output device(s) 624 can be implemented, for example, by display devices (e.g., a light emitting diode (LED), an organic light emitting diode (OLED), a liquid crystal display, a cathode ray tube display (CRT), a touchscreen, a tactile output device, a light emitting diode (LED), a printer and/or speakers). The interface circuit 620 of the illustrated example, thus, may include a graphics driver card, a graphics driver chip or a graphics driver processor. The example input device 622 and output device 624 may be used to implement the user interface 120 of
The interface circuit 620 of the illustrated example also includes a communication device such as a transmitter, a receiver, a transceiver, a modem and/or network interface card to facilitate exchange of data with external machines (e.g., computing devices of any kind) via a network 626 (e,g., an Ethernet connection, a digital subscriber line (DSL), a telephone line, coaxial cable, a cellular telephone system, etc.),
The processor platform 600 of the illustrated example also includes at least one mass storage device 628 for storing executable instructions (e.g., software) and/or data. Examples of such mass storage device(s) 628 include floppy disk drives, hard drive disks, compact disk drives, Blu-ray disk drives, RAID systems, and digital versatile disk (DVD) drives.
The coded instructions 632 of
From the foregoing, it will be appreciated that the above disclosed methods, apparatus and articles of manufacture provide a query manager to generate annotated queries from execution plans selected by an optimizer of a database management system. In some examples, a user may map a query to user annotated queries created by the user to cause the execution engine to process the query in a set manner. Accordingly, the examples herein provide for storage of execution plans for queries that may be used to stabilize timing of retrieving data for a query.
Although certain example methods, apparatus and articles of manufacture have been disclosed herein, the scope of coverage of this patent is not limited thereto. On the contrary, this patent covers all methods, apparatus and articles of manufacture fairly falling within the scope of the claims of this patent.
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/US2015/044193 | 8/7/2015 | WO | 00 |