Query Optimization and Execution Plans

How SQL Server compiles, optimizes, and executes individual queries.

573 associated posts292 primary posts

T-SQL & Development

Don’t Treat SQL Like a Programming or Scripting Language.

In a programming language like C# or Java, you tell the computer what to do, in order. Get the customers from California, then get their invoices, then sum the total. SQL, on the other hand, is a declarative language where you declare the shape of your result set: Get the total sales from Californian customers.…

Read more about Don’t Treat SQL Like a Programming or Scripting Language. 6 comments — Join the discussion
Performance Tuning

When Should You Use DESC in Indexes?

The short answer is that if your query orders columns by a mix of ascending and descending order, back to back, then the index usually needs to match that same alternating order. Now, for the long answer. When you create indexes, you can either create them in ascending order - which is the default: [crayon-6a73d87a02570791880755/] Or…

Read more about When Should You Use DESC in Indexes? 8 comments — Join the discussion