-
2022-11-22
13/802,648
2013-03-13
US 11,507,574 B1
2022-11-22
-
-
Kris E Mackes | Soheila (Gina) Davanlou
ArentFox Schiff LLP
2036-02-27
Smart Summary: A system has been developed to improve how databases handle queries by allowing the choice of different methods for the same task. This flexibility helps the system adapt to changing conditions, leading to better and more reliable performance. In a typical database, several layers work together to process data, from receiving queries to executing them. The goal is to make the query execution process more efficient and robust, which can save time for developers. For example, when filtering data based on certain criteria, this new approach can optimize how that filtering is done. đ TL;DR
A system and method for improved query processing in a database are provided, where different methods of performing the same task can be adaptively chosen. The system can then adapt to different and changing environments, resulting in improved and more stable performance.
Get notified when new applications in this technology area are published.
G06F16/2453 » CPC main
Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data; Querying; Query processing Query optimisation
The disclosure generally relates to a database management system and in particular to a method and system for improving data processing performance by means of adaptive selection of a processing method (âMicro Adaptivityâ).
A Database Management System (DBMS) is a software package that provides a reliable way to store data in a database and process it. One of the main requirements of a DBMS is to provide a coherent interface that allows application developers to manipulate data stored in a database.
The architecture of most DBMSs follows a multilayer approach, where each layer is responsible for another phase of processing. For example, typical DBMS layers may include:
It is desirable to be able to increase the efficiency and robustness of the query executor which results in overall performance improvement and reduced development time.
To demonstrate the need for a more efficient and robust query executor, an example is provided below.
For a simple SQL query, e.g. âSELECT*FROM some_table WHERE some_attribute >7â, the key operation is the selection (filtering) of tuples that match the âsome_attribute >7â predicate. Internally, in database systems, such a selection is implemented using a Primitive function.
The primitive function may be implemented so that it consumes the input column as the âinputâ array, the constant that is compared against as the âvalâ column, and it produces an array âresultâ containing the indices of tuples from âinputâ which match the predicate, returning the number of such tuples as âfoundâ. A simple implementation of such a function could look like:
for (i=0, found=0; i<n; i++)
return found;
The above implementation uses what is known as control-dependencyâdepending on the output of a comparison, a different code path is taken. This behavior is called branching. Modern CPUs have branch-predictor functionality, where they try to guess what will be the path taken in a branch to optimize performance. The problem with branch prediction is that, if the guess incorrectly, additional cost is paid (see âBalancing Vectorized Query Execution with Bandwidth-Optimized Storageâ; Marcin Zukowski; PhD Thesis, University of Amsterdam, Amsterdam, The Netherlands, 2009, Section 5.2.4.2 or âMicro Adaptivity in a Vectorized Database Systemâ; Bogdan Raducanu; MSc Thesis; Vrije Universiteit Amsterdam, 2012, Section 1.1.2.)
Another implementation of the primitive function may be:
for (i=0, found=0; i<n; i++) {result [found]=i;
}
return found;
This implementation uses what is known as data-dependency. Specifically, for each value in the input, the same code is performed. The output of a comparison influences the âfoundâ variable, but does not change the code path taken. Note, that more instructions are executed, as for every input there's some action done, but there is no branching, so the performance is less sensitive to input.
The performance of these two functions varies greatly depending on the input characteristics as shown in FIG. 8. For (popular) cases with selectivities (i.e. percentage of tuples matching the predicate) close to 0% or 100%, the control-dependency solution works very well (up to 2Ă better than data-dependency). This is because the CPU can predict the branch outcome well then, hence no penalty for wrong choices is paid, and fewer instructions are executed. However, for other selectivities, data-dependency solution can be much faster (e.g. 3Ă). This is because the CPU can't guess correctly the outcome of the branch, and even though fewer CPU instructions are actually executed, they are more expensive. Here, avoiding the branch is worth the additional instruction calls.
Since inside the same system various selectivities can be observed (even within the same query) none of these functions would provide an optimal performance overall. It is desirable to provide a method and system that makes query execution not only resistant to, but also benefiting from such performance differences, allowing easy integration with a modern DBMS and it is to this end that the disclosure is directed.
FIG. 1 is a system diagram illustrating an implementation of an operating environment of a database system;
FIG. 2 is a simplified block diagram of an implementation of a computer database system;
FIG. 3 is a block diagram illustrating a preferred tiered implementation of the database system;
FIG. 4 is a block diagram illustrating a possible implementation of the data processing layer in the database system;
FIG. 5 is a block diagram illustrating obtaining a Primitive object in a standard system;
FIG. 6A is a block diagram illustrating obtaining a collection of Primitive Flavors in a system with Micro Adaptivity;
FIG. 6B illustrates more details of an expression evaluator of the microadaptivity system;
FIG. 7 is a flowchart of a method for selecting a primitive using the microadaptivity system;
FIG. 8 presents performance difference between two implementations of the same function performing data selection;
FIG. 9 represents a self-learning Primitive Choice process;
FIGS. 10a-e are diagrams illustrating a performance impact of Micro Adaptivity system with five example types of different primitive flavors; and
FIG. 11 is a diagram illustrating a performance impact of the Micro Adaptivity system on 22 queries from TPC-H.
The disclosure is particularly applicable to a Micro Adaptivity system implemented in a Vectorwise database system and it is in this context that the disclosure will be described. It will be appreciated, however, that the Micro Adaptivity system and method has greater utility since the system and method can be used with any database system. The system and method has a potential of improving query execution efficiency in different database systems, translating to overall system performance. Before describing the details of Micro Adaptivity, an overview of an example of a database system on which the Micro Adaptivity may be implemented is described.
FIG. 1 is a system diagram illustrating an implementation of an operating environment 10 of a database system. In the environment, one or more database server systems 12 host, directly or indirectly, a storage device 14, such as for example a database. Access requests are typically received over a wired or wireless link 16, such as for example, the Internet and intranet or other networks, from various sources such as for example one or more application servers 18 that are each executing on-line transaction processing (OLTP) and/or online analytical processing (OLAP) applications. The specific operations of the applications are typically directed by or executed in support of requests from one or more computing units, such as for example, client applications executed on client computers 20 of various types including mobile computers 22 and communications devices 24. Each computing unit may be a processing unit based device with sufficient processing power, memory and connectivity to interact with the database server system 12. For example, each computing device may be a smartphone (Apple iPhone, RIM Blackberry, Android based devices), a personal computer, a tablet computer and the like.
FIG. 2 is a simplified block diagram of an implementation of a computer database system 30 for the database system 12 that may implement the predictive buffer management method. The database system 30 may include one or more central processing unit (CPU) subsystem 32, implemented for example as a multi-core, multiprocessor subsystem, includes some combination of in-core and close coupled cache subsystem 34 connected to a main memory store 36. In typical embodiments, the cache subsystem 34 will range from 2 to 32 megabytes per core with typically additional, larger cache layers shared among the cores within the CPU subsystem 32 and the main memory 36 will be substantially larger. A portion 36âČ of the main memory store 36 may be implemented to be persistent memory so that the data is maintained even when power is removed, such as by using Flash memory or a conventional backup battery solution. A system controller 38 manages data transfers between the central processing subsystem 32, cache 34, and main memory 36 subsystems through one or more input/output (I/O) controllers 40 that connect, directly or indirectly, to a physical database 42, and I/O devices, including typically a video controller 44 and network interface controller 46. A high-access rate persistent store 48, utilizing a high-performance magnetic or flash emulation disk, may also be provided.
FIG. 3 is a block diagram illustrating a preferred tiered implementation of the database system execution environment 50 that is implemented in or as part of a database engine 52. Database read and update requests are received from one or more applications 54 and satisfied by access to a database 14 containing one or more data tables, such as 561, . . . , 56N as shown in FIG. 3. The one or more applications 54 may be executed local or remote with respect to the database engine 52. The database 14 may be implemented using a physical storage device 42 connected directly to a database server system 12 that executes the database engine 52 or remotely through storage area network (SAN) or other distributed data storage system.
The above database system, including the database engine 52, may implement a Micro Adaptivity system and method. The Micro Adaptivity system and method may be implemented in hardware and interact with a database server or DBMS, but may also be implemented in software and be part of the database engine 52 or database management system (DBMS) that executes on the database servers of the database system.
FIG. 4 is a diagram of a query execution layer 70 that is part of the database engine 52 which manages actual data processing and transformation. The query execution layer may include âOperatorâ objects 71, âPrimitiveâ objects 72 and data storage elements 73, such as vectors when the query execution layer is part of the Vectorwise system. The operator objects 71 represent different possible types of operations including functions that perform low-level data processing operations, specific for different operations which are the primitives 72. This embodiment is given as an example, other variations of this design with similar functionality are possible, and the proposed Micro Adaptivity system and method can be also applied in such designs. More details of this embodiment of the query execution layer 70 are available in Section 4.2 of âBalancing Vectorized Query Execution with Bandwidth-Optimized Storageâ; Marcin Zukowski; PhD Thesis, University of Amsterdam, Amsterdam, The Netherlands, 2009.
In systems built on designs like the query execution layer 70, the relational query, typically provided by the user in SQL, is internally represented as a tree of Operator objects. Each Operator represents a logic specific for a given relational operation (e.g. selection, aggregation or join). This logic is usually the same regardless of the data types used in a particular query, or even details of the operations performedâfor example, Select operator logic is the same if the predicate used is âWHERE x>7â or âWHERE y SIMILAR TO zâ. The query-specific data-processing operations are expressed with Primitive functions. For example, one can have a Primitive function selecting values larger than 7 in a column of floating-point numbers, another that adds two integer attributes, another which extracts a day of week from a date, etc.
A Primitive can provide one of many different functions including selection, computation. A primitive may also implement functions internal to the Operator logic, for example hash value computation, finding an element in a hash table, updating an aggregate etc. As a result, the total number of Primitives in the system can be very high (e.g. thousands of functions). Also, it is typical for Primitive objects to consume the majority of the query processing time. As such, it is important to have simple and automatic ways to guarantee good performance of these functions.
The system may also have specialized primitive objects that are generated for each combination of an operation type and input data types. For example, different Primitive functions will be used to compute âWHERE shipdate <â1998-09-02â depending if âshipdateâ is an attribute of type âdateâ, âtimestampâ etc.
In the embodiment described herein, each Primitive is identified with a âPrimitive Signatureâ representing the above parameter combination. In FIG. 4, for example, a Primitive that selects tuples (âselâ) using a âless thanâ comparison (âltâ) of a date attribute (âcolâ from âcolumnâ) with a date constant (âvalâ from âvalueâ) is identified as âsel_lt_date_col_date_valâ. Today, for each Primitive Signature, there is a single Primitive implementation.
In most database systems, a set of default Primitives are created during the system compilation time, and registered in a âPrimitive Dictionaryâ component. The primitive dictionary provides the function of mapping Primitive Signatures onto the matching Primitive implementation. It is important to note that within a single query plan (a set of queries to be performed in a particular order) there are multiple Primitive functions used and a single Primitive function can be used in multiple parts of the query. Each occurrence of a Primitive in a query plan may be known as a âPrimitive Instanceâ.
FIG. 5 demonstrates the process of obtaining Primitives in a database system. Before a query is executed, in a Query Compilation layer 80, a Primitive Signature 81 may be constructed based on the requested query and may be passed to a Primitive Dictionary 82. The Primitive Dictionary is a component which stores all of the Primitives available in the system and their Primitive Signatures. The Primitive Dictionary finds a Primitive object 83 matching the Primitive Signature 81, and passes it to the Query Execution layer 70, to be used in a given Primitive Instance.
The efficiency of the Primitives (how efficiently the primitive can be executed, how much processing time is needed to execute the primitive, etc.) described above depends on the algorithm chosen to implement each primitive and the way the code was compiled. In addition, the efficiency of the primitives also may be influenced by the environment: hardware, data distributions, query parameters, concurrent query workload, and the interactions between these elements. The high complexity of computer systems, with their complex cache hierarchies, out-of-order execution capabilities and constraints, SIMD instruction support etc. combined with the dynamic aspects of the environments where the primitives are applied, make it impossible to correctly choose one optimal implementation for a particular primitive even for a known workload.
The problem of multiple possible kinds of Primitives for a given Primitive Signature is addressed by Micro Adaptivity system, which allows multiple Primitive implementations. The microadaptivity system improves the raw performance as well as performance stability in the query-execution layer of the database system. Any improvement in this layer directly translates to query performance improvements.
The micro adaptivity system and method adds several elements to a standard database system as shown in FIG. 6A. The elements of the micro adaptivity system in FIG. 6 may each be implemented in hardware (working in conjunction with the database engine 52) or as software that is within the database engine 52. The micro adaptivity system may include:
Primitive Flavors: Instead of having a single Primitive for each Primitive Signature, the system now stores multiple versions of a Primitive for each Primitive Signature. These different versions we call âPrimitive Flavorsâ 84.
Primitive Flavor Libraries: Different Primitive Flavors for the same Primitive Signature can be created using different methods, including: different compilers; different compiler options; different algorithmic implementations. Collections of Primitive Flavors can be compiled together into separate object files known as Primitive Flavor Libraries 86. The system is extended with the ability to link with or dynamically load multiple Primitive Flavor Libraries. Each Primitive Flavor Library registers its Primitive Flavors, under their respective Primitive Signatures, in the Primitive Dictionary, providing additional meta-information (e.g. the source of the Primitive Flavor) useful for e.g. performance profiling or debugging.
Primitive Dictionary Repository 82: This component is extended to be able to store multiple Primitive Flavors for each Primitive Signature. Primitive Flavor Libraries register multiple Primitive Flavors in it. When asked for a particular Primitive Signature, depending on the request type, it can now return either a single (default) Primitive, or a collection of Primitive Flavors, all implementing the functionality of the same Primitive. Primitive Flavors are kept using additional meta-information, which might include: flavor source meta-information (e.g. code version, compiler used, etc), number of times it was used and some performance characteristics, both delivered with primitive as well as gathered during runtime. Primitive Dictionary provides a registration mechanism through which a software component can register and load additional Primitives and Primitive Flavors dynamically on startup or even while the system is active.
Primitive Generation Framework: To generate multiple Primitive Flavors and Primitive Flavor Libraries, a Primitive Generation Framework 85 is used in the microadaptivity system as shown in FIG. 6A. The Primitive Generation Framework 85 creates different implementations based on one or more dimensions such as:
Combination of these dimensions can result in very many Primitive Flavors for the same Primitive. Primitive Generation Framework also provides facility to find identical Primitive Flavors in different Primitive Flavor Libraries and annotate them as such or eliminate them, to reduce the number of Primitive Flavors considered during the Query Execution phase.
Query Execution: In the query execution component 79, for each Primitive Instance, the system observes the performance of different Primitive Flavors, and chooses the one it thinks to be optimal at a given moment that may be known as an Active Flavor. In that flavor-optimization phase, a few optimization techniques may be used: exploitationâonce an Active Flavor is detected, it is being used for some time, to avoid frequent re-optimization, which carries some cost; explorationâperiodically switching to currently inactive flavors to see if their performance might be now better than the Active Flavor; degradation detectionâwhen the performance of the Active Flavor suddenly deteriorates, the system can choose to look at other possibilities. In the implementation in a Vectorwise system, the above logic can be encapsulated in the expression evaluation code, making all changes local and transparent to other parts of the system.
FIG. 6B illustrates more details of the query execution layer 79 that may include an expression evaluator of the microadaptivity system. FIG. 7 is a flowchart of a method 110 for selecting a primitive using the microadaptivity system. Specifically, the query execution layer 79 may include an expression evaluator 100 that evaluates each expression that is part of a query. As part of that expression evaluation, the expression evaluator 100 selects one or more primitives for each expression to perform the query. The expression evaluator 100 may have a primitive optimizer 102 that may select a best flavor for a particular primitive (112) for a particular expression as described in more detail below with an example of an implementation of the primitive optimizer 102. Once the flavor of a primitive is selected (and becomes the active flavor), the primitive is passed onto a primitive executor 104 that executes the active flavor (114) of the primitive for the particular query. As described below, the flavor of a particular primitive may be changed (116) and reoptimized. In this manner, the microadaptivity system and method adjust and optimizes, on a primitive level, the specific flavor of a primitive used to execute a particular query expression at a particular time.
The microadaptivity system may have different kinds of Primitive-generation aspects where different Primitive Flavors with different performance characteristics are possible. The below list is for example only and not exhaustive.
Compiler Variations (Different Compilers and/or Compiler Options
One of the easiest ways to obtain different flavors is to compile the primitive with different compilers and switches.
Branch vs. No-Branch
An example of context-dependent performance are branching and non-branching implementations of Selection primitives. The branching primitives use the if statements to test a predicate while the non-branching primitives use logical operators and index arithmetic to completely remove any branching.
The selection primitive in Listing 1 above accepts as arguments a vector col of ints and its size n, a constant val, and a vector res where to store the result. It produces a selection vector with the indices of the elements in the input vector which have a value strictly less than the constant value. The selection vector is then passed to other primitives. The Branching implementation in Listing 1 uses a branch while the primitive shown in Listing 2 below is branchfree (No-Branching). These implementations are functionally equivalent: they always produce the same result.
The No-Branching implementation is Listing 2 always performs the same number of operations, while with Branching, this depends on the data. If the data is such that the branch is almost never taken, then the Branching implementation will do less work, as it avoids executing the code that generates a result. What is the fastest implementation depends on the data
Loop Fission
Certain implementation of a database management system, such as Vectorwise, uses bloom filters to accelerate hash-table lookups in situations where the key is often not found. Using a bloom filter is faster because hash-table lookup is CPU-intensive and the hash-table may not be in the CPU cacheâwhereas a bloom filter might fit as it is much smaller, and lookup is quick and simple. Still, the bloom filter may not fit the CPU cache, and the lookup primitive displayed in Listing 5 below then incurs a cache miss in the bf_get( ) call.
Note, that this is a Selection primitive, identifying tuples surviving the bloom filter check, and uses a No-Branching code style.
The loop fussion optimization of this bloom filter check is displayed in Listing 6 above. Rather than identifying the selected tuples inside the same loop, it just collects the Boolean result of bf_get( ) in a temporary array, and then selects from there in a separate loop. The idea behind this loop fussion variant is that it removes all dependencies between iterations of the first loop.
The loop fussion variant, when it sustains a cache miss in bf_get( ), allows the CPU to continue executing the next loop iteration(s), leveraging the large out-of-order execution capabilities of modern CPUs (>100 instructions). This way the CPU will get multiple (up to 5, on Ivy Bridge) loop iterations in execution at any time, leading to 5 concurrent outstanding cache misses, maximizing memory bandwidth utilization. In contrast, the non-ssion variant causes the iterations to wait on each other due to the loop-iteration dependency, thus achieves less concurrent cache misses and therefore lower memory throughput.
Micro-benchmarks were performed in which the number of unique keys was varied from 212 to 227, which required bloom filters with sizes from 4 KB to 131072 KB. The testing revealed that, for large bloom lters, fussion performs better, indeed sometimes 50% faster; whereas for small bloom filters where there are no cache misses fussion can be slower, sometimes by 15%.
Hand-Unrolling
The primitives in the database engine may be template-generated. The templates are used to provide type-specific versions of the same function (e.g. multiplication of integers, of doubles, of short integers, etc.). Additionally, these template macros instantiate all possible parameter combinations of vector vs. constant (e.g multiply values from two vectors, a vector with a constant or a constant with a vector). Template macros insert a body action, such as the multiplication of values, in a loop over the input vector(s).
By changing these templates, as in Listing 7 above, a user manually introduced a well known loop-unrolling optimization into the primitives.
Query Execution Logic Details
With multiple Primitive Flavors available from the Primitive Dictionary for each Primitive Signature, the Query Execution component has to be able to make the right decision on which of the Primitive Flavors to choose for the actual data processing.
In one implementation, the system may track of the performance of each Primitive Flavor for each Primitive Instance. The typical metric used is the number of CPU clocks for each processed record. Thus, for each Primitive Flavor, the time of the last N calls is stored and the average of it is used as the expected cost in the next call.
To choose the Primitive Flavor, a self-learning Primitive Choice Process may be used. In one embodiment, presented in FIG. 9, this process works as follows:
The process above was shown to choose the optimal flavor with high accuracy and low overhead. The process may be optionally extended with a special initial exploration phase, during which all known flavors are first tested one after another on the input dataâthis provide complete information for the follow up exploration and exploitation phases.
For example, the process to select/optimize the primitive may be implemented as follows:
In addition to the above described primitive selection, the microadaptivity system may have a data recorder component that record data during the execution of each query. The recorded data may include statistics about the data being processed (e.g. selectivity, cardinality). The recorded data may also include performance of executed function implementations (e.g. CPU cycles spent, number of cache misses). The recorded data may be made persistent, such as being stored in a persistent memory or storage device) so that the recorded data may be reloaded when the system starts. The recorded data may be used to perform decisions on which flavor of a primitive to choose in the next iteration of a given primitive.
Benchmark Results
The MicroAdaptivity system and method was tested on a set of the 22 queries from the TPC-H Benchmark (See [TPC-H]) using a 100 GB generated database.) For the different types of aspects listed above that influence primitive generation, primitives were tested using one of the possible approaches. During the test, how well MicroAdaptivity performed dynamically choosing primitives was measured. In addition, the testing simulated the âoptimalâ process where, for each function call, the testing measured the time of the fastest of the available flavors.
FIGS. 10(a)-10(e) demonstrates these results. For each primitive-generation aspect, the testing used one implementation as a base. The testing then measured the time spent in all primitives influenced by this aspect and then performance improvement over this base result of different options within this aspect, as well as of the Micro Adaptive and Optimal solutions. The results demonstrate that there often is a significant performance difference between different flavors. For example, for loop-fission optimization (FIG. 10(c)), primitives always applying this optimization are on average 1.40Ă faster. Still, in all cases neither of the flavors is optimal. Micro Adaptivity manages to consistently provide significant performance improvements over every single flavor, and is consistently close to the optimal solution.
FIG. 11 demonstrates a total performance benefit of Micro Adaptivity over the 22 used TPC-H queries. Here, the testing also compared it to a system where different flavors are chosen not based on observed performance, but on heuristics. For example, the âbranchingâ flavor is used for selectivities below 10% and above 90% and the âno-branchingâ flavor is used in other cases. Even over such a system heuristics, Micro Adaptivity consistently provides an advantage (in terms of the number of seconds to perform each query.) FIG. 11 also demonstrates a very important benefit of Micro Adaptivity from the software engineering perspective. Since software systems usually ship with only a single implementation of performance-critical functions, the shipped function is often the one performing best on average, providing a compromise for different options. Finding such âbest averageâ function is very work-intensive, especially if the system has many functions. Also, the âbest averageâ function might be best only on some hardware, while on other (including future hardware), other solutions might perform better. This is demonstrated by FIG. 10(c). When the âloop fissionâ optimization was considered in Vectorwise in 2009, the hardware used at that moment benefited only partially from this optimization, hence it was not enabled. In 2012, it is clear that this is a better option by default. With Micro Adaptivity, engineers can put all promising flavors into the system, and let the Micro Adaptivity framework decide which one to choose dynamically. The above results demonstrate that Micro Adaptivity can be beneficial for performance, by choosing the best function flavors and avoiding bad ones, but can also provide benefits in software engineering time, reducing time spent on complex and error-prone code tuning.
While the foregoing has been with reference to a particular embodiment of the invention, it will be appreciated by those skilled in the art that changes in this embodiment may be made without departing from the principles and spirit of the disclosure, the scope of which is defined by the appended claims.
1. A data processing system, comprising:
a computer having a processor;
a database engine having a query execution component on the computer that can adapt an execution of a plurality of queries, wherein each query has one or more primitive functions that are used to evaluate the query, each primitive function having one or more instructions configured to be executed by the query execution component;
the database engine storing a plurality of flavors for each primitive function, wherein each flavor of each primitive function is a primitive function using a manual loop unrolling and a primitive function that does not use the manual loop unrolling;
an expression evaluator on the computer that evaluates each expression in each query; and
a primitive optimizer on the computer that selects a flavor of a primitive function for each primitive function-used in each query.
2. The system of claim 1, wherein the primitive optimizer switches between the plurality of flavors for each primitive function.
3. The system of claim 2 further comprising a data recorder that records data associated with the execution of each query using a selected flavor of each primitive function in each query.
4. The system of claim 3, wherein the data associated with the execution of each query is statistics about the data being processed in each query.
5. The system of claim 3, wherein the data associated with the execution of each query is a measure of performance of the flavor of each primitive function executed for each query.
6. The system of claim 3, wherein the data recorder persistently stores the data so the data is reloaded.
7. The system of claim 3, wherein the primitive optimizer uses the data to choose a flavor of a primitive function.
8. The system of claim 2, wherein the primitive optimizer uses an initial exploration phase to study performance of each flavor of a primitive function.
9. The system of claim 3, wherein the primitive optimizer uses an exploration phase during which the data recorded for each query is ignored and an exploitation phases during which the data recorded for each query is used to switch between the plurality of flavors for a primitive function.
10. The system of claim 1 further comprising a repository that stores the plurality of flavors for each primitive function.
11. The system of claim 10, wherein the repository stores one or more flavors and a process to select the flavor of the primitive function.
12. The system of claim 10, wherein the repository contains the plurality of flavors of a primitive function, wherein each flavor of the primitive function is generated by one of compiling the primitive function with a different compiler and compiling the primitive using a different compile option.
13. The system of claim 10, wherein the repository contains a plurality of flavors of memory accessing primitives function.
14. The system of claim 10, wherein the repository contains a plurality of flavors of map functions.
15. The system of claim 10, wherein the repository contains a plurality of flavors of memory prefetching instructions at multiple prefetch distances.
16. The system of claim 11, wherein the repository stores a plurality of processes to select the flavor of the primitive, wherein the processes include a process using control dependency and a process using data dependency.
17. The system of claim 11, wherein the one or more flavors of a primitive is a primitive using a manual loop unrolling.
18. A method for selecting a primitive to be used in a query of a database, the method comprising:
storing a plurality of flavors for each primitive function, wherein each flavor of each primitive function is a primitive function using a manual loop unrolling and a primitive function that does not use the manual loop unrolling;
exploring, during an explore period, a flavor of a primitive function to select as an active flavor, the primitive function having one or more instructions configured to be executed by a query execution component; and
selecting, during an exploitation phase following the explore period, an active flavor for the primitive function based on data about an execution of one or more queries.
19. The method of claim 18, wherein exploring the flavor of a primitive function further comprises selecting pseudorandomly the flavor of the primitive function based on one of an equal probability to each flavor and a higher probability of a predetermined flavor.
20. The method of claim 19, wherein the selected flavor of the primitive function is used during an explore length time period and further comprising capturing data about the execution of the selected flavor of the primitive function.
21. The method of claim 20, wherein selecting during the exploitation phase further comprises using the selected active flavor during an exploit length.
22. The method of claim 21 further comprising re-optimizing, at the end of the exploit length, the plurality of flavors for the primitive function based on data about an execution of one or more queries.