A read from order_items times out on every run, at about 15 s.
- Why
- Its plan repeats a read of
order_items1.5M times, once per row: the query forces a loop join, where one hash join over a single pass would do. - Fix
- Remove
OPTION (LOOP JOIN)and let the optimizer choose. - Verify
- Run it with actual rows: a hash join, and far fewer executions of
order_items.