English 中文(简体)
我如何发现哪些指数正在使用? 如何使用该指数?
原标题:How do I find which indexes are being used and what query is using the index?

我正在使用2008年的服务器。 我有重复指数的表格(基本指数,定义相同)。 我想知道,它是否能够找到使用这些指数的询问? 我不知道为什么首先编制重复指数。 因此,在去除这些地雷之前,我想查明使用这些地雷的任何问题。

以上情况还有一个问题,即Kingk服务器发动机如何确定使用哪些指数? 这对业绩有何影响?

Thanks aski

最佳回答

如果您的数据库中存在准确重复的索引,删除这些索引的时间。 消除重复不会造成任何伤害,但因现有重复产生危害。

服务器甚至允许首先制作重复指数,这是荒谬的。

Here is an article on how to find unused (and missing) indexes: http://weblogs.sqlteam.com/mladenp/archive/2009/04/08/SQL-Server---Find-missing-and-unused-indexes.aspx

问题回答

如果指数真的重复,那么它就应当使用matter<>em>? 如果你去掉一个名字,那么问询就应当使用另一个名字(除非有人问,该名字很少)。

确保指数真正重复:

  • Indexed field order matters. An index on (fname, lname) is not the same as an index on (lname, fname)
  • An index on (lname) is reduntant if you already have one on (lname, fname, ...other fields) (Going from the left only, order matters here, too)
  • Check included fields. Similar looking indexes might have different included fields to cover different queries (although you could probably still consolidate these by making one index with all included fields)
  • Other properties of the index might cause one index to behave slightly different than the other (clustered? Unique? Fill Factor? Max degree of parallelism? Filegroup? Auto-recompute stats?) (You still probably wouldn t need 2 different indexes, but worth understanding the differences, anyway)

凭借债务管理和金融分析系统(动力管理观点),你可以肯定地发现,哪些指数是用的,哪些是长期使用的。

检查:

One more question is in above cases, how does SQL Server engine determine which index to use?

这是一种极其复杂的过程,即服务器组别优化器将利用统计和其他方法来估算哪些指数有助于某个特定问题。 当你有两个相同之处时,哪一个是小问题。 我不知道,非常诚实。

这对业绩有何影响?

是否有相同的指数? 这些需要保留在任何涉及指数各栏内容的INSERT、UPDATE和DELETE业务上,因此,你肯定会为此支付履约惩罚。





相关问题
How to write this T-SQL WHERE condition?

I ve got two tables: TableA Col1 Col2 TableB Col3 Col4 I want to join them together: SELECT * from TableA join TableB ON (...) Now, in place of ... I need to write an expression ...

Customer and Order Sql Statement

TSQL query to select all records from Customer that has an Order and also select all records from customer that does not have an Order. The table Customer contains a primary key of CustomerID. The ...

Recommended way of querying multiple Versioned tables

Have a win 2003 box with MSSQL 2005 running on it. There is a database which is populated every morning with new/modified SalesOrder made the previous day. The database has several tables: SalesOrder, ...

update duplicate record

I have a table with the following fields Id Name IsPublic i need to write a sql query that updates IsPublic to false where name has a duplicate. Only one of the duplicates should have IsPublic = ...

Define variable to use with IN operator (T-SQL)

I have a Transact-SQL query that uses the IN operator. Something like this: select * from myTable where myColumn in (1,2,3,4) Is there a way to define a variable to hold the entire list "(1,2,3,4)"? ...

Selecting records during recursive stored procedure

I ve got a content management system that contains a hierarchical structure of categories, with sub-categories subject to different ordering options at each level. Currently, that s retrieved by a (...