Details
-
New Feature
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
Description
When optimizing queries shaped like
SELECT ... FROM t_state s JOIN t_big b ON b.state_id = s.id
|
WHERE s.name IN ('a','b')
|
AND (SELECT val FROM t_attr WHERE t_attr.obj_id = b.id) = 'X';
|
the optimizer doesn't take into account the cost of the subquery which is re-evaluated for every row. Optimizer's WHERE_COST constant is calculated expecting two simple conditions in the WHERE part. That sometimes lead to selection of inefficient execution plans like shown in the scripts attached.
Investigate whether it's possible to account correlated subqueries in attached conditions too.