Could someone tell me how sql server decides what query plan to use? We looked at a select statement at work that had several joins and date ranges. It was taking several minutes to run. We were trying to clean it up and we took out a few 'upper' statement not thinking it would do anything. The query now returns in a matter of seconds. The Execution plan is completely different for the two queries. Why would an 'upper' cause a different execution plan and such different performance?
Thanks,
Eddie