At this point, you should have a good understanding of how to build a T-SQL query, but how do we build an elegant T-SQL query? We want one that not only gets the job done but does so efficiently. There are a few guidelines that are important to keep in mind when writing T-SQL queries to ensure that they perform and scale well. For this purpose, this chapter discusses some basics of database physical design structure, such as indexes, as well as how the Query Optimizer estimates cost and chooses what data access methods must be used, based on how the query is written.
In this chapter, the following topics will be covered:
- Understanding predicate SARGability
- Basic index guidelines
- Best practices for T-SQL querying