Methods of optimizing access to a relation queried through a number of
predicates. The methods identify one or more candidate predicates of the
selection condition that can be used to factorize the selection
condition. A gain from using one or more of the candidate predicates to
factorize the selection condition is computed. One or more of the
candidate predicates that result in a positive gain are factored from the
selection condition to produce a rewritten selection condition. The
candidate predicates can be predicates that appear exactly in the
selection condition more than once and/or merged predicates that may be
predicates in the selection condition that overlap.