Using indexed views in SQL Server (materialized view)

Source: Internet
Author: User

Materialized view: The normal view used before, the normal view is a logic statement, the performance does not have any elevation, and can not create indexes, and materialized view will be the view of the data queried in the database to create a snapshot, it and the physical table, can be created index, PRIMARY key constraints and so on, performance will have a qualitative improvement, But it has shortcomings, will occupy, you can set it to automatically update a time, can also be manually updated, of course, can be set up in time to update, but will slow down the base table of additions and deletions to check the operation, here I only talk about ideas, specific words we can study on their own.

+ View Code?
--创建物化视图,每天晚上22:00:00自动更新 create materialized view VM_PSNPERSONINFO refresh force on demand start with sysdate next to_date( concat( to_char( sysdate+1,‘dd-mm-yyyy‘),‘ 22:00:00‘),‘dd-mm-yyyy hh24:mi:ss‘) as SELECT dt.personid, c.employeeid,d.unitcode,d.unitname,d.label,        dt.unitid,dt.startdate,dt.enddate   FROM (          SELECT DISTINCT b.personnelid personid,SUBSTR (a.effectdate, 1, 10) startdate,          MIN (CASE WHEN a.effectdate < b.effectdate THEN b.effectdate ELSE N‘9999-99-99‘ END) AS enddate,          MIN (a.adjustresult) unitid          FROM psnadjust a LEFT JOIN psnadjust b          ON a.personnelid = b.personnelid          WHERE a.adjusttype = ‘2‘ AND b.adjusttype = ‘2‘          GROUP BY b.personnelid, a.effectdate         ) dt        INNER JOIN psnaccessioninfo c            ON c.personid = dt.personid        INNER JOIN orgstdstruct d            ON d.unitid = dt.unitid ORDER BY employeeid, unitcode, startdate;

  

Http://www.cnblogs.com/zhxhdean/archive/2011/05/16/2047795.html

http://blog.163.com/[email protected]/blog/static/561082842007235010598/

Http://www.cnblogs.com/liuzhendong/archive/2011/10/10/2205744.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.