Improve performance with SQL Server 2005 indexed view Two

Source: Internet
Author: User
Tags definition create index empty join

View Restrictions

To create an index on a view in SQL Server 2005, the corresponding view definition must include:

Any, not any OPENROWSET, OPENQUERY, OpenDataSource

Arithmetic OPENXML on imprecise (floating, real) values

COMPUTE, COMPUTE by

CONVERT generates an inexact result OUTER join

COUNT (*) refers to a base table with a disabled clustered index

GROUP by all references tables or functions in different databases

A derived table (a subquery in the From list) references another view

DISTINCT ROWSET function

EXISTS, not EXISTS self-join

Aggregate results (for example: SUM (x) +sum (x)) expression STDEV, STDEVP, VAR, VARP, AVG

Full-text predicates (CONTAINS, FREETEXT, CONTAINSTABLE, freetexttable) subqueries

An inexact constant (for example: 2.34e5) A SUM on an empty expression

Inline or table-valued function table hints (e.g., NOLOCK)

MIN, MAX text, ntext, image, FileStream, or XML column

Non-deterministic expression top

Non-Unicode sort UNION

The conflicting scenarios that SQL Server 2005 can detect indicate that the view will be empty (for example, when 0=1 and ... )

Note Indexed views may contain floating and solid columns, but they cannot be included in a clustered index key if such columns are not persisted.

GROUP by limit

If there is a GROUP By,view defined as:

Must contain COUNT_BIG (*).

Must not contain having, CUBE, ROLLUP, or GROUPING ().

These restrictions apply only to indexed view definitions. Even if the GROUP by limit is not met, the query can also use an indexed view in its execution plan.

Requirements for indexing

The user executing the CREATE INDEX statement must be the view owner.

If the view definition contains a GROUP BY clause, the key of the unique clustered index can only refer to the column specified by the GROUP BY clause.

You must not create an index with the IGNORE_DUP_KEY option enabled.

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.