有一个视图V_1,其定义的sql语句如下:
select col11 col1,col12 col2,col13 col3,'A' ctype from table1
union all
select col21,col22,col23,'B' ctype from table2
union all
select col31,col32,col33,'C' ctype from table3如下的sql语句调用视图:select * from V_1 where cType='B'
考查执行计划,发现sql server将table1、table2、table3都扫描了,效率很低(我的table3是大表,其他的都是小表)。但显然的,sql server仅需要扫描table2即可得到我要查询的数据。
请问:如何优化让sql server仅去查询table2呢?