Patent ID: 7343369

Claim:
A method for predicting the selectivity of a set of at least one logical query condition for querying a database, said at least one logical query condition comprising at least one join condition for joining multiple tables of said database, comprising the steps of: automatically identifying at least one skewed value for a first field of said database specified in said at least one join condition; for each skewed value identified by said step of automatically identifying at least one skewed value, automatically constructing a corresponding set of one or more hypothetical query predicates, each hypothetical query predicate of said set of hypothetical query predicates corresponding to a respective query condition of said set of at least one logical query condition, wherein each respective said hypothetical query predicate is constructed by replacing each occurrence of said first field in the corresponding query condition with a constant equal to the skewed value corresponding to the set of hypothetical query predicates containing the hypothetical query predicate; automatically predicting a respective selectivity for each said set of hypothetical query predicates; and automatically predicting a composite selectivity for said set of at least one logical query condition using the respective selectivity for each said set of hypothetical query predicates, wherein said step of automatically predicting a composite selectivity for said set of at least one logical query condition comprises automatically predicting a residual selectivity for said set of at least one logical query condition, said residual selectivity being predicted as a selectivity of a hypothetical database which does not contain said skewed values, and automatically combining said residual selectivity with said respective selectivity for each said set of hypothetical query predicates to produce said composite selectivity.