Understanding Query Optimizer: Testing Which Query is Better

Guys I have 2 queries, the old one was very slow. It used a CTE, and selected ROW 1 from each group. I rewrote the query to get rid of the other rows because they were not needed. At first the stored proc seemed 10 times faster. But over time, testing and testing, and testing, there wasn't a clear difference in performance. I don't know a lot about the query optimizer.

What is the best way to tell which sql is performing better? Is this hard to do?


Typically you look at the query plan. You could also review the logical I/O (reads, etc.).

check the query plan and review the indexes accordingly