续:有关SQL SERVER分布统计的问题(5)
来源:未知 责任编辑:责任编辑 发表时间:2014-02-02 17:50 点击:次
50: INSERT INTO #TMP(ColStats_Stream, ColRows, ColData_Pages)
51: EXEC ('DBCC SHOW_STATISTICS ("' + @Table_Name + '", "'+@Stats_Name+'") WITH STATS_STREAM')
52: ;WITH CTE_Temp AS (SELECT TOP (@@RowCount) * FROM #TMP ORDER BY ID DESC)
53: UPDATE CTE_Temp
54: SET Table_Name = @Table_Name,
55: Column_Name = @Column_Name,
56: Stats_Name = @Stats_Name
57: SELECT TOP 1 @i = ROWID,
58: @Table_Name = Table_Name,
59: @Column_Name = Column_Name,
60: @Stats_Name = Stats_Name
61: FROM @Tab
62: WHERE ROWID > @I
63: END
64: GO
65: SELECT SUM(DATALENGTH(ColStats_Stream) / 1024.) AS [Size KB]
66: FROM #TMP
67: GO
68: SELECT Table_Name,
69: Column_Name,
70: Stats_Name,
71: ColStats_Stream,
72: DATALENGTH(ColStats_Stream) / 1024. AS [Size KB]
73: FROM #TMP
74: ORDER BY [Size KB] DESC
从Size KB列可以知道每一个统计对象使用的字节数。
作者 Yuejun Sun
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>