I am trying to create a partitioned view, however my execution plan is showing that it is still accessing both underlying tables.
Why is my query still accessing both underlying tables and then concatenating them?
I am trying to create a partitioned view, however my execution plan is showing that it is still accessing both underlying tables.
Why is my query still accessing both underlying tables and then concatenating them?
Copyright © 2021 Jogjafile Inc.
Most likely the issue is that your
CHECKConstraint does not match yourWHEREcondition.Your Check Constraints are in the form of:
Your
WHEREcondition is in the form of:Change your Check Constraints to use full dates (plus there is no need to use a function --
DATEPART-- for such a simple filter). The following is for the 2016 table:Repeat that for the other tables, changing the year in both predicates to match the year of the table.
Please note that the syntax above does not state the time component because the field in question is a
DATEdatatype. If the datatype wereDATETIME, then the end of the range would need to be expressed as:For more info on Partitioned Views, please see the MSDN page for Using Partitioned Views.