Patent ID: 7457797

Claim:
A method for executing a database query in a computer system, comprising the steps of: automatically generating a re-usable query execution strategy for a database query, said database query containing at least one condition comparing a first database field to an imported variable value, said re-usable query execution strategy employing a database subset data structure containing data from a subset of records in said database, said subset having a scope defined with reference to said first database field, said re-usable query execution strategy being re-usable for multiple execution invocations of said database query, each execution invocation including a respective instance of said imported variable value; automatically generating a query execution strategy condition expression associated with said re-usable query execution strategy, said query execution strategy condition expression expressing at least one condition on use of said query execution strategy, said at least one condition limiting said imported variable value to a range of values in which said at least one condition of said query is within a scope of said database subset data structure, wherein said step of automatically generating a query execution strategy condition expression comprises: negating a predicate referencing said first database field contained in a subset definition expression defining the scope of said database subset data structure, inserting said negated predicate into said at least one condition of said query comparing a first database field to an imported variable value, and performing a transitive closure of the expression resulting from said inserting step, wherein said database subset data structure comprises data joined from a plurality of database tables; invoking said database query including a first instance of said imported variable value; evaluating said query execution strategy condition expression using said first instance of said imported variable value; and using said query execution strategy to execute said database query including said first instance of said imported variable value depending on results of said evaluating step.