17

SQL Server 2005/2008でテーブルの読み取り数と書き込み数に関する統計を見つける方法はありますか?

DMVs/DMFsトリガーや監査を使用せずに特に探しています。

ここでの目標は、インデックスの適切な FILL FACTORを見つけることです。この記事 ( FILL FACTOR DEFINED ) からアイデアを得ました。


[更新] ServerFault に関するフォローアップの質問があり
ます DMV/DMF 統計から読み取り/書き込み集中テーブルを決定する方法

4

4 に答える 4

23

次のクエリを使用して、データベース内のすべてのテーブルの読み取りと書き込みの数を見つけることができます。このクエリ結果は CSV ファイルにエクスポートでき、Excel の数式を使用して読み取り/書き込み比率を簡単に計算できます。テーブルのインデックスを計画する際に非常に便利

DECLARE @dbid int
SELECT @dbid = db_id('database_name')

SELECT TableName = object_name(s.object_id),
       Reads = SUM(user_seeks + user_scans + user_lookups), Writes =  SUM(user_updates)
FROM sys.dm_db_index_usage_stats AS s
INNER JOIN sys.indexes AS i
ON s.object_id = i.object_id
AND i.index_id = s.index_id
WHERE objectproperty(s.object_id,'IsUserTable') = 1
AND s.database_id = @dbid
GROUP BY object_name(s.object_id)
ORDER BY writes DESC
于 2012-02-22T12:28:25.177 に答える
14

「テーブル」は、クラスター化されたインデックスまたは「ヒープ」を意味することに注意してください。

于 2009-10-15T23:49:03.967 に答える
3

To determine an appropriate fill factor for a table's indexes, you need to look at the number of page splits occuring. This is shown in sys.dm_db_index_operational_stats:

Leaf allocation count: Total number of page splits at the leaf level of the index.

Nonleaf allocation count: Total number of page splits above the leaf level of the index.

Leaf page merge count: Total number of page merges at the leaf level of the index.

After doing a bit of digging, I've seen a few posts that say the page split numbers from the DMV's are not that useful (I haven't personally confirmed this), but there is also a performance counter "page splits/sec" (but it's is only at SQL Server instance level).

I use the rule of thumb that ordinary tables use the default 90% fill factor, high insert tables somewhere between 70 - 85% (depending on row size). Read only tables can utilise a fill factor of 100%

于 2009-10-15T23:54:54.487 に答える