Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Constraint still allows scanning on field

Status
Not open for further replies.

sqlwp

Programmer
Joined
Jan 23, 2004
Messages
24
Location
US
I have multiple tables that I union together into a view. Each table has a check constraint on it for the same field but different value for each table. When I do a select on the view including the constraint field in the where clause the execution plan still shows all tables in the view being scanned. Shouldn't the existence of the constraint on the tables prevent SQL from needing to do a scan on the tables that don't contain the value I'm looking for in the check constraint field?
 
From my past studies on this subject, I was under the same impression.

For what it's worth, the predicted query execution plan is not always identical to the actual plan chosen when the query is run...

What data type is the column you have the check constraint on to do this partitioned view?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top