关于物化视图
来源:http://topic.csdn.net/t/20011008/09/315001.html? smartdonkey(聪明的毛驴) ? ? 物化视图,所谓视图实际上是不存储物理信息的(同表相区别,表存储世纪的数据和表的索引信息等。),试图仅仅存储一个select语句而已。而物化视图就要视图也存储实际的数据,这种实际数据,就是索引。oracle ? 8i和mssqlserver2000中引入的。比如oracle的函数索引和sqlserver2000的索引视图都是物化视图。原因是这种视图能够显著提高性能,据个例子 ? ? 一个表:create ? mytable ? (id ? int ? not ? null,name ? varchar(20) ? not ? null) ? ? create ? index ? idx_mytable ? on ? mytable.name ? ? 当我们查询的时候,select ? * ? from ? mytable ? where ? name ? like ? 'j%',优化器能够使用索引来提高性能,然而我们遇到这种情况就不能使用索引了,如: ? ? select ? * ? from ? mytable ? where ? name ? like ? '%bing%' ? ? 或者 ? ? select ? * ? from ? mytable ? where ? substring(name,1,5)='jiang' ? ? 这样的情况不能使用索引 ? ? 但引入物化视图就不同了 ? ? create ? view ? myview(vid,vname) ? as ? select ? id,substring(name,5) ? from ? myview. ? ? 然后再vname上建立索引即可显著提高查询性能。 ? ? oracle的函数索引亦是如此。 ? ? create ? index ? idx_mytable ? on ? mytable(upper(name)) ? ? -- ? ? 就是这样的?? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |