Archive for October 14th, 2009
Answering questions asked on the site.
I was wondering: do the constraints declared on tables in SQL Server affect the decisions made by the optimizer?
SQL Server allows to define the following constraints on the columns:
Since these constraints imply some restrictions on data, it gives a theoretical possibility to use these restrictions while optimizing the queries so that some extra checks (which had already been made by the constraints) can be skipped.
SQL Server does use these possibilities and optimizes its plans taking the constraints into account.
In this article we will see how SQL Server uses
PRIMARY KEY and
UNIQUE to optimize the plans.
PRIMARY KEY and UNIQUE
Let's create a pair of sample tables:
Read the rest of this entry »