Queries are optimized according to a first optimization mode by generating
execution plans and selecting the lowest cost plan. Inputs optimized
according to the first optimization mode, to database operations with
input parameters that are inconsistent with the first optimization mode,
are replaced with equivalent inputs optimized according to a second
optimization mode, the second optimization mode being consistent with the
input parameter. Blocking operations are eliminated from queries using a
cost-based approach.