SQL Server Tuning----index missing

Source: Internet
Author: User
Tags create index

SELECT

Mig.index_group_handle, Mid.index_handle,

CONVERT (Decimal (28,1),

Migs.avg_total_user_cost * Migs.avg_user_impact * (Migs.user_seeks + Migs.user_scans)

) as Improvement_measure,

' CREATE index idx_ ' + object_name (object_id,database_id) + ' _missing_ ' +

Replace (replace (replace (ISNULL (Mid.equality_columns, ') + ' _ ' +

ISNULL (Mid.inequality_columns, '), ', ', ' _ '), ', '), ' [', ' '), '] ', ') +

' On [' + object_name (object_id,database_id) + '] (' + ISNULL (mid.equality_columns, ')

+ Case when Mid.equality_columns was not null and mid.inequality_columns was not null then ', ' ELSE ' END

+ ISNULL (mid.inequality_columns, ")

+ ') ' + isnull (' Include (' + included_columns + ') ', ') + ' with (Online=on) ' as Create_index_statement,

migs.*, mid.database_id, mid.[object_id]

From Sys.dm_db_missing_index_groups mig

INNER JOIN sys.dm_db_missing_index_group_stats MiGs on migs.group_handle = Mig.index_group_handle

INNER JOIN sys.dm_db_missing_index_details mid on mig.index_handle = Mid.index_handle

WHERE CONVERT (Decimal (28,1), Migs.avg_total_user_cost * migs.avg_user_impact * (Migs.user_seeks + Migs.user_scans)) ; 10

ORDER by Migs.avg_total_user_cost * Migs.avg_user_impact * (Migs.user_seeks + Migs.user_scans) DESC

SQL Server Tuning----index missing

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.