Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
BRH 6
Index 6
Non-Clustered Index 5
Performance 4
#SQLServer 3
#TSQL 2
SQLServer 2
Clustered Index 2
Filtered Index 2
SSMS 2

Archive · View All
April 2010 7
March 2010 4
August 2010 2
May 2010 2
October 2011 1
September 2010 1

If you don’t know anything about the indexes in your databases

Apr 21 2010 2:57PM by Dinesh Asanka   

Having discuss indexes in some what details, this post will give some queries to get the index information of you databases.

Ok, if you are a DBA, most of the time you need to manage some others databases. In my carrier, it is only few occasions where I was given task to design fresh database. All the other occasions, it is managing heritage databases, which you can’t avoid.

So in this case, you don’t know, what are the indexes, which table has which index so on.

You need some queries to get that information.

We discussed that it is much much better to have at least a primary key for a table. If you want to list out table which does not have primary key, this is the query to get the list of tables with no primary keys.

SELECT  Object_Schema_name(object_ID) + '.' + name AS [tables with no primary keys]
FROM    sys.tables
WHERE   OBJECTPROPERTY(object_id, 'TableHasPrimaryKey') = 0
ORDER BY 1

Next thing you look for is indexes and following query will list you the tables which you don’t have at least one index.

SELECT  Object_Schema_name(object_ID) + '.' + name AS [Tables with no indexes]
FROM    sys.tables
WHERE   OBJECTPROPERTY(object_id, 'TableHasIndex') = 0
ORDER BY 1

In the previous post we discussed effect on many indexes. So if you want to find out which tables have most indexes, execute the following query.

SELECT TOP 5
        Object_Schema_name(t.object_ID) + '.' + t.name AS [Table],
        COUNT(1) AS [Indexes]
FROM    sys.indexes i
        INNER JOIN sys.objects t ON i.object_ID = t.object_ID
GROUP BY Object_Schema_name(t.object_ID) + '.' + t.name
ORDER BY COUNT(1) DESC

If you closely analyze these queries, you can see you are using two system tables sys.tables and sys.indexes. then we are using two system functions, OBJECT_SCHEMA_NAME and OBJECTPROPERTY.

Tags: Index, Non-Clustered Index, BRH, Performance,


Dinesh Asanka
116 · 1% · 444
1
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"If you don’t know anything about the indexes in your databases" rated 5 out of 5 by 1 readers
If you don’t know anything about the indexes in your databases , 5.0 out of 5 based on 1 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]