dcsimg
 

Tables Without Clustered Indexes

Thursday May 3rd 2018 by Greg Larsen

Do all of your tables contain clustered indexes? Some say every table should have a clustered index. Greg Larsen shares a simple script to identify those tables in your database that don’t have a clustered index.

Do all of your tables contain clustered indexes?  Some say every table should have a clustered index.  Others say it depends.  When databases are being designed and developed, your developers might have overlooked creating clustered indexes on some of your database tables.  Having a useful clustered index on your tables will improve the performance of your queries, especially if you are returning data periodically in order by the clustered index key.  Here is a simple script to identify those tables in your database that don’t have a clustered index. 

-- Tables without clustered indexes
SELECT TOP 1000 o.name, i.type_desc, o.type_desc, o.create_date
FROM sys.indexes i
INNER JOIN sys.objects o
ON  i.object_id = o.object_id
WHERE o.type_desc = 'USER_TABLE'
AND i.type_desc = 'HEAP'
ORDER BY o.name;
GO

See all articles by Greg Larsen

Home
Mobile Site | Full Site