Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit aa2eff4

Browse files
make it more compact
1 parent fb06efe commit aa2eff4

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

‎QueryTemplates/Common Scripts/partitions-stats.sql‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
--paritioned table and index details
2-
--paritioned table and index details
32
SELECT
43
SCHEMA_NAME(o.schema_id) AS SchemaName,
54
OBJECT_NAME(p.object_id) AS ObjectName,
6-
i.[name] AS IndexName,
5+
i.name AS IndexName,
76
p.index_id AS IndexID,
8-
ds.name AS PartitionScheme,
7+
--ds.name AS PartitionScheme,
8+
--pf.name AS PartitionFunction,
99
p.partition_number AS PartitionNumber,
10-
fg.name AS FileGroupName,
10+
--fg.name AS FileGroupName,
1111
prv_left.value AS LowerBoundaryValue,
1212
prv_right.value AS UpperBoundaryValue,
13-
CASE pf.boundary_value_on_right
14-
WHEN 1 THEN 'RIGHT'
15-
ELSE 'LEFT' END AS Range,
16-
FORMAT(p.[rows], 'N0') AS [Rows],
13+
--CASE pf.boundary_value_on_right WHEN 1 THEN 'RIGHT' ELSE 'LEFT' END AS [Range],
14+
FORMAT(p.rows, 'N0') AS [Rows],
1715
p.[data_compression_desc] AS [Compression]
1816
FROM sys.partitions AS p
1917
JOIN sys.indexes AS i ON i.object_id = p.object_id AND i.index_id = p.index_id
@@ -26,12 +24,11 @@ JOIN sys.filegroups AS fg ON fg.data_space_id = dds2.data_space
2624
LEFT JOIN sys.partition_range_values AS prv_left ON ps.function_id = prv_left.function_id AND prv_left.boundary_id = p.partition_number - 1
2725
LEFT JOIN sys.partition_range_values AS prv_right ON ps.function_id = prv_right.function_id AND prv_right.boundary_id = p.partition_number
2826
WHERE
29-
OBJECTPROPERTY(p.object_id, 'ISMSShipped') = 0
30-
AND p.index_id = 1 /* only show clustered index */
27+
p.index_id = 1 /* only show clustered index */
3128
--AND OBJECT_NAME(p.object_id) = ''
3229
--AND i.[name] = ''
3330
--AND p.partition_number = 0
34-
--AND p.[rows] > 0
31+
--AND p.[rows] > 0
3532
ORDER BY
3633
ObjectName, IndexID, PartitionNumber
3734

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /