Query Optimization: Tips and Tricks

Identify ways to improve the performance of important queries.

Publish Date: 7/12/2023
eBook

Execution plans provide a rich source of information that can help us identify ways to improve the performance of important queries. People often look for things like large scans and lookups as a way to identify potential data access path optimizations. These issues can often be quickly resolved by creating a new index or extending an existing one with more included columns.

This article explores this latter type of analysis, using a simple example problem of finding unique column values in a moderately large data set. As is often the case in analogous real-world problems, the column of interest will have relatively few unique values compared with the number of rows in the table. There are two parts to this analysis: creating the sample data and writing the distinct-values query itself.