1. A computer-readable medium containing a program which, when executed on a database contained within a database system, performs an operation, comprising: decomposing the primary query into a plurality of conditional groups, wherein each conditional group is a fragment of the primary query, and wherein the conditional groups are logically related to one another; generating a secondary query for each of the two or more conditional groups; executing at least one of the secondary queries; combining the results of the secondary queries based on the logical relationships between the conditional groups; and returning the combined results of the secondary queries as the result of the primary query.