{"id":6345,"date":"2019-03-09T13:25:14","date_gmt":"2019-03-09T13:25:14","guid":{"rendered":"https:\/\/ittutorial.org\/?p=6345"},"modified":"2019-11-28T07:04:28","modified_gmt":"2019-11-28T07:04:28","slug":"sql-server-missing-index","status":"publish","type":"post","link":"https:\/\/ittutorial.org\/sql-server-missing-index\/","title":{"rendered":"SQL Server Missing Index"},"content":{"rendered":"<p>Hi,<\/p>\n<p>The use of Index in the SQL Server database occurs in environments that require the most performance, speed, and memory savings.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3681\" src=\"https:\/\/ittutorial.org\/wp-content\/uploads\/2014\/03\/index2.gif\" alt=\"\" width=\"543\" height=\"248\" \/><\/p>\n<p><!--more--><\/p>\n<p>&nbsp;<\/p>\n\n<p>In a table with millions or billions of records, we can use a Index\u00a0 to read fewer records and search less to find related record.<\/p>\n<p>Accurately created Index, millions of records within the database we have searched within a very short time to bring the record of the caller&#8217;s convenience, while at the same time less read the record by reaching the target record, we use the operating system resources effectively.<\/p>\n<p>You should create index for mostly read only queries on a table.\u00a0 If Delete,update operations are more than read only queries, you should not create index that table.<\/p>\n<p>You can look at the missing index recommendation of SQL Server with following script. You can create missing index but you should monitor these index, If they are not useful, you should drop them.<\/p>\n<p>&nbsp;<\/p>\n<pre>SELECT MID.[statement] AS ObjectName\r\n,MID.equality_columns AS EqualityColumns\r\n,MID.inequality_columns AS InequalityColms\r\n,MID.included_columns AS IncludedColumns\r\n,MIGS.last_user_seek AS LastUserSeek\r\n,MIGS.avg_total_user_cost \r\n* MIGS.avg_user_impact \r\n* (MIGS.user_seeks + MIGS.user_scans) AS Impact\r\n,N'CREATE NONCLUSTERED INDEX &lt;TYPE_Index_Name&gt; ' + \r\nN'ON ' + MID.[statement] + \r\nN' (' + MID.equality_columns \r\n+ ISNULL(', ' + MID.inequality_columns, N'') +\r\nN') ' + ISNULL(N'INCLUDE (' + MID.included_columns + N');', ';')\r\nAS CreateStatement\r\nFROM sys.dm_db_missing_index_group_stats AS MIGS\r\nINNER JOIN sys.dm_db_missing_index_groups AS MIG\r\nON MIGS.group_handle = MIG.index_group_handle\r\nINNER JOIN sys.dm_db_missing_index_details AS MID\r\nON MIG.index_handle = MID.index_handle\r\nWHERE database_id = DB_ID()\r\nAND MIGS.last_user_seek &gt;= DATEDIFF(month, GetDate(), -1)\r\nORDER BY Impact DESC;\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<h4><span style=\"color: #ff0000;\">Do you want to learn Microsoft SQL Server DBA Tutorials for Beginners, then read the following articles.<\/span><\/h4>\n<p><a href=\"https:\/\/ittutorial.org\/sql-server-tutorials-microsoft-database-for-beginners\/\">https:\/\/ittutorial.org\/sql-server-tutorials-microsoft-database-for-beginners\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, The use of Index in the SQL Server database occurs in environments that require the most performance, speed, and memory savings.<\/p>\n","protected":false},"author":1,"featured_media":3681,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2227],"tags":[2357,1028,1031,2355,1600,1610,2231,2356,1648,2262,2261,2232,2354,2258,2237,2236,2230,2229],"class_list":["post-6345","post","type-post","status-publish","format-standard","has-post-thumbnail","","category-sql-server-2","tag-index-recommendation-sql-server","tag-mehmet-deveci","tag-mehmet-salih-deveci","tag-missing-index-sql-server","tag-sql-server-2012","tag-sql-server-2014","tag-sql-server-2019","tag-sql-server-create-index","tag-sql-server-index","tag-sql-server-index-usage","tag-sql-server-index-usage-stats","tag-sql-server-inventory-script","tag-sql-server-missing-index","tag-sql-server-rebuild-index","tag-sql-server-select-inventory","tag-sql-server-select-machine-name","tag-sql-server-useful-query","tag-sql-server-useful-script"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/ittutorial.org\/wp-content\/uploads\/2014\/03\/index2.gif","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/6345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/comments?post=6345"}],"version-history":[{"count":4,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/6345\/revisions"}],"predecessor-version":[{"id":12964,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/posts\/6345\/revisions\/12964"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/media\/3681"}],"wp:attachment":[{"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/media?parent=6345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/categories?post=6345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ittutorial.org\/wp-json\/wp\/v2\/tags?post=6345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}