Subject query problems
Author mp527
In the following query from a stored proc the left join is killing
the performance, query takes from 5 to 10 minutes.

I can't post the plan right now because my stupid VPN stopped
accepting my logon.

/*Get assets of Fixed Income holding type */
for select distinct common_account_detail.account_id,
common_security.security_id,
common_security.cusip,common_rating_definition.rank,
common_rating_definition.quality_rating_description
from common_account_detail
join common_positions on
common_account_detail.account_id=common_positions.account_id
join common_security on
common_positions.security_id=common_security.security_id
left join (common_rating_security_map join common_rating_definition
on
common_rating_security_map.quality_rating_id=common_rating_definition
.quality_rating_id )
on common_security.security_id=common_rating_security_map.security_id
WHERE ((common_security.security_type_id=3)AND
((common_rating_definition.rating_source_id=2) or
(common_rating_definition.rating_source_id is null)))
/* order by
common_account_detail.account_number,common_security.security_id */
into :account_id_var, :security_id_var, :cusip_var, :rank_var, :ratin
g_description_var do
begin
if (rank_var > 9) then
begin
/* add to exception list */
error_var='Fixed Income asset quality rating is outside the
acceptable range.';
execute procedure SPCOMP_INSERT_EXCEPTION
(5,:account_id_var,cusip_var,security_id_var,null,9,rank_var,:error_v
ar);
end

end