Identifying queries with nested loops
The following query identifies queries that have had alert events logged for nested loops. For information on how to fix the nested loop condition, see Nested loop.
select query, trim(querytxt) as SQL, starttime from stl_query where query in ( select distinct query from stl_alert_event_log where event like 'Nested Loop Join in the query plan%') order by starttime desc;