Techniques are provided for determining query cost for a query that
include an outer query and at least a first subquery. The techniques
include determining a filtering factor for the first subquery based on a
first cardinality and a second cardinality. The first cardinality is
determined based on a first set of query blocks in the query. The second
cardinality is determined based on a second set of query blocks. The
first set of query blocks includes the outer query and zero or more
subqueries from the query and does not include the first subquery. The
second set of query blocks includes all the query blocks in the first set
of query blocks and, in addition, the first subquery. The techniques also
include determining a cost for the query based, at least, on the
filtering factor for the first subquery.