Patent ID: 8762366

Claim:
A method for executing database queries, comprising: receiving a database query for execution by a database system, the database system configured to process database queries using a first processing unit including one or more central processing units (CPUs) and a second processing unit including one or more single instruction multiple thread based processing units; generating, by the database system, an intermediate executable representation including code for processing the database query, the code comprising instructions for execution by a database virtual machine, the processing performed by executing operators representing portions of computations for processing the database query; generating native code from the intermediate executable representation, wherein the native code is optimized for execution on the second processing unit, wherein generating native code comprises: identifying a conditional branch statement in which the execution of instructions on a first branch takes more units of time than execution of instructions on a second branch of the code; and introducing one or more dummy instructions in the second branch of code, wherein the number of dummy instructions introduced in the second branch of code is determined so as to cause the execution of the first branch and the second branch to take the same number of units of time for execution; compiling the native code to executable code; selecting, by the database system, a target processing unit for executing an operator of the database query based on factors comprising the data processed by the query; responsive to selection of the second processing unit for executing the operator of the database query, executing the compiled executable code by the database system using the second processing unit; and sending the result of execution of the query.