Tables without clustered indexes defined

This metric measures the number of tables without clustered indexes defined that contain more than 1000 rows per database.

Install metric...

Metrics install automatically if you have SQL Monitor installed.

If you are using Redgate’s SQL Server monitoring tool, SQL Monitor, you can instantly install and run this metric on your servers.

This metric measures the number of tables without clustered indexes defined that contain more than 1000 rows per database. It is good practice to define the clustered index for every table in the database to help improve query performance.

Note: Having a clustered index per table is NOT compulsory. There are cases, where a heap (table without a clustered index) is acceptable.

To analyze further, the following query can be used to find out which indexes don’t have clustered indexes defined:

[sql]WITH CTE_1
AS
(
SELECT db_name() as dbname,
o.name as tablename,
(SELECT SUM(p.rows)
FROM sys.partitions p
WHERE p.index_id = i.index_id
AND i.object_id = p.object_id) as number_of_rows
FROM sys.indexes i
INNER JOIN sys.objects o
ON i.object_id = o.object_id
WHERE OBJECTPROPERTY(o.object_id, ‘IsUserTable’) = 1
AND OBJECTPROPERTY(o.object_id, ‘TableHasClustIndex’) = 0
)
SELECT *
FROM CTE_1
WHERE number_of_rows > 1000;[/sql]

Tables without clustered indexes defined, 5.0 out of 5 based on 1 rating

Metric definition

Name

Tables without clustered indexes defined

Description

This metric measures the number of tables without clustered indexes defined that contain more than 1000 rows per database. It is good practice to define the clustered index for every table in the database to help improve query performance.

Note: Having a clustered index per table is NOT compulsory. There are cases, where a heap (table without a clustered index) is acceptable.

To analyze further, the following query can be used to find out which indexes don't have clustered indexes defined:

WITH CTE_1
AS
(
  SELECT db_name() as dbname,
         o.name as tablename,
         (SELECT SUM(p.rows)
            FROM sys.partitions p
           WHERE p.index_id = i.index_id
             AND i.object_id = p.object_id) as number_of_rows
    FROM sys.indexes i
   INNER JOIN sys.objects o
      ON i.object_id = o.object_id
   WHERE OBJECTPROPERTY(o.object_id, 'IsUserTable') = 1
     AND OBJECTPROPERTY(o.object_id, 'TableHasClustIndex') = 0
)
SELECT *
  FROM CTE_1
 WHERE number_of_rows > 1000;

The T-SQL query that will collect data

Instances to collect from

Select all

Databases to collect from

1

Collection frequency

86400

Use collected or calculated values

Leave the Use a calculated rate of change between collections check box unchecked

Metric collection

Enabled

Alert definition

Alert name

Tables without clustered indexes

Description

This alert is raised when the number of tables without clustered indexes defined that contain more than 1000 rows per database exceeds set thresholds. It is good practice to define the clustered index for every table in the database to help improve query performance.

Note: Having a clustered index per table is NOT compulsory. There are cases, where a heap (table without a clustered index) is acceptable.

To analyze further, the following query can be used to find out which indexes don't have clustered indexes defined:

WITH CTE_1
AS
(
  SELECT db_name() as dbname,
         o.name as tablename,
         (SELECT SUM(p.rows)
            FROM sys.partitions p
           WHERE p.index_id = i.index_id
             AND i.object_id = p.object_id) as number_of_rows
    FROM sys.indexes i
   INNER JOIN sys.objects o
      ON i.object_id = o.object_id
   WHERE OBJECTPROPERTY(o.object_id, 'IsUserTable') = 1
     AND OBJECTPROPERTY(o.object_id, 'TableHasClustIndex') = 0
)
SELECT *
  FROM CTE_1
 WHERE number_of_rows > 1000;

Raise an alert when the metric value goes

Above the defined threshholds

Default threshold values

High:500
Medium:100
Low:0

Note: These thresholds are intended as guideline values. If they seem too high or too low for your environment, replace them with values more suited to your server performance.

Raise an alert when the threshold is passed for

1 collection

Alert is

Enabled