A query facility for database queries saves and re-uses query execution
strategies, and automatically determines whether a strategy can be
re-used when an imported variable changes. The query facility
automatically saves one or more logical conditions associated with the
one or more imported variables in the query. When the query is reused,
the logical conditions are evaluated using the imported variable values,
and the previously saved execution strategy is used only if the condition
or conditions are met. Preferably, the logical conditions express a range
of imported variable values which are included in a database subset data
structure used by the saved query execution strategy, such as a
materialized query table or partitioned table. Logical conditions are
preferably generated by negating the predicates from a logical expression
defining the applicability of the execution strategy, inserting the
negated predicates into the query, and performing a transitive closure.