现在的视图是:
select id, userid, description  from table1
union
select id, userid, description  from table2
union
select id, userid, description  from table3
....
union
select id, userid, description  from table16
这样的视图是不能建索引的。
所以怀疑起不到性能提升的作用,反倒跟单表操作没什么区别了。

解决方案 »

  1.   

    用union all建立的视图应该是可以建立索引的吧?
    select id, userid, description  from table1
    union all
    select id, userid, description  from table2
    union all
    select id, userid, description  from table3
    ....
    union all
    select id, userid, description  from table16
      

  2.   

    --可以建立索引,不过,这样使数据的更新和删除更慢!频繁做DML 操作,还可能产生数据库死锁!
      

  3.   

    只要有UNION就不能建索引,提示:
    无法对视图 ... 创建 索引,因为其中包含一个或多个 UNION、INTERSECT 或 EXCEPT 运算符。如果将查询作为原始视图的 UNION、INTERSECT 或 EXCEPT 运算符的输入,请考虑为每个这样的查询创建一个单独的索引视图。"为每个这样的查询创建一个单独的索引视图"肯定是没有意义的。