Claims
- 1. A method of executing a database query, the method comprising:
(a) dynamically evaluating at least one performance criterion for a query during execution of at least a portion of the query; (b) selecting one of a plurality of query implementations defined in the query based upon the dynamically-evaluated performance criterion; and (b) continuing execution of the query using the selected query implementation.
- 2. The method of claim 1, wherein the performance criterion is associated with a runtime-derived parameter.
- 3. The method of claim 1, wherein the performance criterion is associated with a parameter selected from the group consisting of an attribute, a record count, an environmental statistic, and combinations thereof.
- 4. The method of claim 1, wherein dynamically evaluating the performance criterion includes accessing a query data structure that includes the plurality of query implementations to obtain the performance criterion, and wherein continuing execution of the query includes executing the selected query implementation in the query data structure.
- 5. The method of claim 4, wherein the query data structure includes a query tree having a switch node and a plurality of child nodes, the switch node configured to evaluate the performance criterion and at least one of the child nodes configured to implement at least a portion of one of the plurality of query implementations.
- 6. The method of claim 5, wherein the query tree includes a plurality of binary switch nodes, each binary switch node including a performance criterion, wherein each binary switch node includes a left subtree that implements one of the plurality of query implementations that matches the performance criterion.
- 7. The method of claim 6, wherein each binary switch node other than a last binary switch node references as its right child another of the binary switch nodes, and wherein the last binary switch node includes a right subtree that implements a default query implementation.
- 8. The method of claim 5, wherein dynamically evaluating the performance criterion includes executing an attribute operation list associated with the switch node.
- 9. The method of claim 1, wherein dynamically evaluating the performance criterion is performed during absolute positioning.
- 10. An apparatus, comprising:
(a) a memory within which is resident at least a portion of a database; and (b) program code configured to execute a database query by dynamically evaluating at least one performance criterion for the query during execution of at least a portion of the query, selecting one of a plurality of query implementations defined in the query based upon the dynamically-evaluated performance criterion, continuing execution of the query using the selected query implementation.
- 11. The apparatus of claim 10, wherein the performance criterion is associated with a runtime-derived parameter.
- 12. The apparatus of claim 10, wherein the performance criterion is associated with a parameter selected from the group consisting of an attribute, a record count, an environmental statistic, and combinations thereof.
- 13. The apparatus of claim 10, wherein the program code is configured to dynamically evaluate the performance criterion by accessing a query data structure that includes the plurality of query implementations to obtain the performance criterion, and to continue execution of the query by executing the selected query implementation in the query data structure.
- 14. The apparatus of claim 13, wherein the query data structure includes a query tree having a switch node and a plurality of child nodes, the switch node configured to evaluate the performance criterion and at least one of the child nodes configured to implement at least a portion of one of the plurality of query implementations.
- 15. The apparatus of claim 14, wherein the query tree includes a plurality of binary switch nodes, each binary switch node including a performance criterion, wherein each binary switch node includes a left subtree that implements one of the plurality of query implementations that matches the performance criterion.
- 16. The apparatus of claim 15, wherein each binary switch node other than a last binary switch node references as its right child another of the binary switch nodes, and wherein the last binary switch node includes a right subtree that implements a default query implementation.
- 17. The apparatus of claim 14, wherein the program code is configured to dynamically evaluate the performance criterion by executing an attribute operation list associated with the switch node.
- 18. The apparatus of claim 10, wherein the program code is configured to dynamically evaluate the performance criterion during absolute positioning.
- 19. A program product, comprising:
(a) program code configured to execute a database query by dynamically evaluating at least one performance criterion for the query during execution of at least a portion of the query, selecting one of a plurality of query implementations defined in the query based upon the dynamically-evaluated performance criterion, continuing execution of the query using the selected query implementation; and (b) a signal bearing medium bearing the program code.
- 20. The program product of claim 19, wherein the signal bearing medium includes at least one of a transmission medium and a recordable medium.
- 21. A program product, comprising:
(a) a query data structure for use in implementing a query, the query data structure including a plurality of implementations of at least a portion of the query, and at least one performance criterion for use in selecting one of the plurality of implementations to execute during execution of the query; and (b) a signal bearing medium bearing the query data structure.
- 22. A computer-implemented method of generating a query data structure, the method comprising:
(a) identifying a plurality of implementations capable of implementing at least a portion of a query; and (a) building a query data structure for use in implementing the query, the query data structure including the plurality of implementations and at least one performance criterion for use in selecting one of the plurality of implementations to execute during execution of the query.
- 23. The method of claim 22, wherein identifying the plurality of implementations and building the query data structure are performed during query optimization.
- 24. The method of claim 22, further comprising sorting the plurality of implementations to order the plurality of implementations from best to worst.
- 25. The method of claim 22, wherein building the query data structure includes associating a performance criterion with each of at least a subset of the plurality of implementations.
- 26. The method of claim 25, wherein associating the performance criterion with each of the subset of the plurality of implementations includes associating a performance criterion with every implementation except for a default implementation.
- 27. The method of claim 22, wherein building the query data structure includes building a query object, the query object including a query tree having a switch node and a plurality of child nodes, the switch node configured to evaluate the performance criterion and at least one of the child nodes configured to implement at least a portion of one of the plurality of implementations.
CROSS-REFERENCE TO RELATED APPLICATIONS
[0001] This application is related to U.S. Ser. No. ______ , filed on even date herewith by David Glenn Carlson et al. and entitled “PARALLEL DATABASE QUERY PROCESSING FOR NON-UNIFORM DATA SOURCES VIA BUFFERED ACCESS” (hereinafter “Carlson I”) (IBM ROC920010234US1), to U.S. Ser. No. ______ , filed on even date herewith by David Glenn Carlson et al. and entitled “METHOD FOR EFFICIENT PROCESSING OF MULTI-STATE ATTRIBUTES” (hereinafter “Carlson II”) (IBM ROC920010305US1), and to U.S. Ser. No. ______ , filed on even date herewith by David Glenn Carlson et al. and entitled “OBJECT-ORIENTED QUERY EXECUTION DATA STRUCTURE” (hereinafter “Carlson III”) (IBM ROC920020104US1). The disclosures of each of these applications are incorporated by reference herein.