Clustered Index Usage

Oct 17, 2007

I am looking for some expert opinions on when is it not appropriate to use a clustered index on a table?


Future guru in the making.

View 13 Replies


ADVERTISEMENT

Simple Query Chooses Clustered Index Scan Instead Of Clustered Index Seek

Nov 14, 2006

the query:

SELECT a.AssetGuid, a.Name, a.LocationGuid
FROM Asset a WHERE a.AssociationGuid IN (
SELECT ada.DataAssociationGuid FROM AssociationDataAssociation ada
WHERE ada.AssociationGuid = '568B40AD-5133-4237-9F3C-F8EA9D472662')

takes 30-60 seconds to run on my machine, due to a clustered index scan on our an index on asset [about half a million rows].  For this particular association less than 50 rows are returned. 

expanding the inner select into a list of guids the query runs instantly:

SELECT a.AssetGuid, a.Name, a.LocationGuid
FROM Asset a WHERE a.AssociationGuid IN (
'0F9C1654-9FAC-45FC-9997-5EBDAD21A4B4',
'52C616C0-C4C5-45F4-B691-7FA83462CA34',
'C95A6669-D6D1-460A-BC2F-C0F6756A234D')

It runs instantly because of doing a clustered index seek [on the same index as the previous query] instead of a scan.  The index in question IX_Asset_AssociationGuid is a nonclustered index on Asset.AssociationGuid.

The tables involved:

Asset, represents an asset.  Primary key is AssetGuid, there is an index/FK on Asset.AssociationGuid.  The asset table has 28 columns or so...
Association, kind of like a place, associations exist in a tree where one association can contain any number of child associations.  Each association has a ParentAssociationGuid pointing to its parent.  Only leaf associations contain assets. 
AssociationDataAssociation, a table consisting of two columns, AssociationGuid, DataAssociationGuid.  This is a table used to quickly find leaf associations [DataAssociationGuid] beneath a particular association [AssociationGuid].  In the above case the inner select () returns 3 rows. 

I'd include .sqlplan files or screenshots, but I don't see a way to attach them. 

I understand I can specify to use the index manually [and this also runs instantly], but for such a simple query it is peculiar it is necesscary.  This is the query with the index specified manually:

SELECT a.AssetGuid, a.Name, a.LocationGuid
FROM Asset a WITH (INDEX (IX_Asset_AssociationGuid)) WHERE
a.AssociationGuid IN (
SELECT ada.DataAssociationGuid FROM AssociationDataAssociation ada
WHERE ada.AssociationGuid = '568B40AD-5133-4237-9F3C-F8EA9D472662')

To repeat/clarify my question, why might this not be doing a clustered index seek with the first query?

View 15 Replies View Related

DB Engine :: How To Convert Unique Clustered Index Into Clustered Primary Key To Use With Change Tracking

Sep 4, 2015

We are going to use SQL Sever change tracking. The problem is that some of our tables, which are to be tracked, have no primary keys. There are only unique clustered indexes. The question is what is the best way to turn on change tracking for these tables in our circumstances.

View 4 Replies View Related

DB Design :: Script To Create Table With Primary Key Non-clustered And Clustered Index

Aug 28, 2015

I desire to have a clustered index on a column other than the Primary Key. I have a few junction tables that I may want to alter, create table, or ...

I have practiced with an example table that is not really a junction table. It is just a table I decided to use for practice. When I execute the script, it seems to do everything I expect. For instance, there are not any constraints but there are indexes. The PK is the correct column.

CREATE TABLE [dbo].[tblNotificationMgr](
[NotificationMgrKey] [int] IDENTITY(1,1) NOT NULL,
[ContactKey] [int] NOT NULL,
[EventTypeEnum] [tinyint] NOT NULL,

[code]....

View 20 Replies View Related

Data Warehousing :: Difference Between Primary Key With Clustered And Non-clustered Index

Jul 19, 2013

I have created two tables. table one has the following fields,

                      Id -> unique clustered index.
         table two has the following fields,
                      Tid -> unique clustered index
                      Id -> foreign key of table one(id).

Now I have created primary key for the table one column 'id'. It's created as "nonclustered, unique, primary key located on PRIMARY". Primary key create clustered index default. since unique clustered index existed in table one, it has created "Nonclustered primary key".

My Question is, What is the difference between "clustered, unique, primary key" and "nonclustered, unique, primary key"? Is there any performance impact between these?

View 5 Replies View Related

Create Clustered Or Non-clustered Index On Large Table ( SQL Server 7 )

Jan 4, 2008

I have large table with 10million records. I would like to create clustered or non-clustered index.

What is the quick way to create? I have tried once and it took more than 10 min.

please help.

View 1 Replies View Related

Converting A Clustered Index On A PK Identity Field To Non-clustered

Sep 8, 2006

Hi there, I have a table that has an IDENTITY column and it is the PK of this table. By default SQL Server creates a unique clustered index on the PK, but this isn't what I wanted. I want to make a regular unique index on the column so I can make a clustered index on a different column.

If I try to uncheck the Clustered index option in EM I get a dialog that says "Cannot convert a clustered index to a nonclustered index using the DROP_EXISTING option.". If I simply try to delete the index I get the following "An explicit DROP INDEX is not allowed on index 'index name'. It is being used for PRIMARY KEY constraint enforcement.

So do I have to drop the PK constraint now? How does that affect all the tables that have FK relationships to this table?

Thanks

View 3 Replies View Related

Include Clustered Index In Non-clustered Index?

Oct 15, 2007

Hi everybody!

I just ran the Database Engine Tuning Advisor on a relative complex query to find out if a new index might help, and in fact it found a combination that should give a performance gain of 94%. Fair enough to try that.

What I wonder about: The index I should create contains 4 columns, the last of them being the Primary Key column of the table, which is also my clustered index for the table. It is an identity integer btw.

I think I remember that ANY index does include the clustered one as lookup into the data, so having it listed to the list of columns will not help. It might at worst add another duplicate 4 bytes to each index entry.

Right? Wrong? Keep the column in the index, or remove it since it is included implicit anyway?

Thanks for suggestions!
Ralf

View 3 Replies View Related

Clustered Index On Client_ID+ORderNO+OrdersubNo, If I Create 3 Noncluster Index On Said Column Will It Imporve Performance

Dec 5, 2007



Dear All.

We had Teradata 4700 SMP. We have moved data from TD to MS_SQL SERVER 2003. records are 19.65 Millions.

table is >> Order_Dtl

Columns are:-

Client_ID varchar 10
Order_ID varchar 50
Order_Sub_ID decimal
.....
...
..
.
Pk is (ClientID+OrderId+OrderSubID)

Web Base application or PDA devices use to initiate the order from all over the country. The issue is this table is not Partioned but good HP with 30 GB RAM is installed. this is main table that receive 18,0000 hits or more. All brokers and users are using this table to see the status of their order.

The always search by OrderID, or ClientID or order_SubNo, or enter any two like (Client_ID+Order_Sub_ID) or any combination.

Query takes to much time when ever server receive more querys. some orther indexes are also created on the same table like (OrderDate, OrdCreate Date and Status)

My Question are:-


Q1. IF Person "A" query to DB on Client_ID, then what Index will use ? (If any one do Query on any two combination like Client_ID+Order_ID, So what index will be uesd.? How does MS-SQL SERVER deal with these kind of issues.?

Q2. If i create 3 more indexes on ClientID, ORderID and OrdersubID. will this improve the performance of query.if person "A" search record on orderNo so what index will be used. (Mind it their would be 3 seprate indexes for Each PK columns) and composite-Clustered index is also available.?

Q3. I want to check what indexes has been used? on what search?

Q4. How can i check what table was populated when, or last date of update (DML)?

My Limitation is i Dont Create a Partioned table. I dont have permission to do it.



In Teradata we had more than 4 tb record of CRM data with no issue. i am not new baby in db line but not expert in sql server 2003.


I am thank u to all who read or reply.

Arshad

Manager Database
Esoulconsultancy.com

(Teradata Master)
10g OCP










View 3 Replies View Related

Clustered And Non Clustered Index On Same Columns

Nov 1, 2007

I have a table<table1> with 804668 records primary on table1(col1,col2,col3,col4)

Have created non-clustered index on <table1>(col2,col3,col4),to solve a performance issue.(which is a join involving another table with 1.2 million records).Seems to be working great.

I want to know whether this will slow down,insert and update on the <table1>?

View 2 Replies View Related

Advantages Of Using Nonclustered Index After Using Clustered Index On One Table

Jul 3, 2006

Hi everyone,
When we create a clustered index firstly, and then is it advantageous to create another index which is nonclustered ??
In my opinion, yes it is. Because, since we use clustered index first, our rows are sorted and so while using nonclustered index on this data file, finding adress of the record on this sorted data is really easier than finding adress of the record on unsorted data, is not it ??

Thanks

View 4 Replies View Related

SQL 2012 :: Clustered Index Key Order In NC Index

Mar 5, 2015

I have a clustered index that consists of 3 int columns in this order: DateKey, LocationKey, ItemKey (there are many other columns in this data warehouse table such as quantities, prices, etc.).

Now I want to add a non-clustered index on just one of the other columns, say LocationKey, like this:
CREATE INDEX IX_test on TableName (LocationKey)

I understand that the clustered index keys will also be added as key columns to any NC indexes. So, in this case the NC index will also get the other two columns from the clustered index added as key columns. But, in what order will they be added?

Will the resulting index keys on this new NC index effectively be:

LocationKey, DateKey, ItemKey
OR
LocationKey, ItemKey, DateKey

Do the clustering keys get added to a NC index in the same order as they are defined in the clustered index?

View 1 Replies View Related

Clustered Index Vs. Full Text Index

Jun 18, 2008

Quick question about the primary purpose of Full Text Index vs. Clustered Index.

The Full Text Index has the purpose of being accessible outside of the database so users can query the tables and columns it needs while being linked to other databases and tables within the SQL Server instance.
Is the Full Text Index similar to the global variable in programming where the scope lies outside of the tables and database itself?

I understand the clustered index is created for each table and most likely accessed within the user schema who have access to the database.

Is this correct?

I am kind of confused on why you would use full text index as opposed to clustered index.

Thank you
Goldmember

View 2 Replies View Related

Clustered Index Or NonClustered Index

Apr 1, 2006

Hello I want to learn disparity clustered index or nonclustered index and in queries which one run better.

example

select * from orders where orderID=5

to this query clustered or nonclustered

thanks



View 3 Replies View Related

Clustered/non-Clustered Index

Dec 6, 2005

What does an index add to the performance?
Why do we use Clustered Index and Non-clustered Index?
 
thanks

View 3 Replies View Related

Index Usage

Aug 24, 2000

Hi all,
I need to drop some of my indexes to keep the size of my DB manageable. I know they're not all being used, but what is the best way to determine how often they are being used? Statistics? I haven't come across any text referring to this so any help is appreciated.

Pete Karhatsu

View 1 Replies View Related

Index Usage

Aug 14, 2007

Does SQL Server store somewhere (in a table that I can query) when last an index was used by any queries?
Or does it store which query plans it's a part of?

View 4 Replies View Related

Index Usage Through DMV's

Sep 27, 2007

Hi all,


When i execute the following query on my database, to see the index usage information,

-------------------------------------------------------------------------------------------

use databasenamego

SELECT OBJECT_NAME(S.[OBJECT_ID]) AS [OBJECT NAME], I.[NAME] AS [INDEX NAME],

USER_SEEKS, USER_SCANS,

USER_LOOKUPS,

USER_UPDATES FROM SYS.DM_DB_INDEX_USAGE_STATS AS S

INNER JOIN SYS.INDEXES AS I ON I.[OBJECT_ID] = S.[OBJECT_ID]

AND I.INDEX_ID = S.INDEX_ID

WHERE OBJECTPROPERTY(S.[OBJECT_ID],'IsUserTable') = 1

-----------------------------------------------------------------------------------------

I see for some indexes, the columsn User_seeks= 0, User_scans = 0 .

Does this mean that, those indexes are not being used .


I wanted to know, what is the best way & best criteria to look for, in order to find whether particular index is being used (or) not.( Probalby,We can use DTA , but i believe , there should some way through DMV's also)


Because by keeping unncessary indexes, performance can be hammered on a table whose size is 170 Gb with 9 Non-clustered indexes , 1 clustered


Need some advice on this.

Thanks..

View 4 Replies View Related

Index - Clustered Or Not?

May 22, 2000

Hi,
I have a small table (around 10,000 rows) that is constantly selected from, deleted from, and inserted into. Basically we fill it with content, our web application selects the content, and when we run out, we regenerate (about 50 rows at a time). We currently have a nonclustered PK on the first two columns, both INTs. How can I determine if a clustered index would be better? I am concerned about bottlenecks due to a hotspot with the nonclustered index. When our site really starts to get users, this could become a big issue. I am thinking that I could use a clustered index, and set up a job to reindex the table once every hour or so....any help is appreciated greatly.

View 3 Replies View Related

Clustered Index

Dec 9, 2000

Does anybody know if a key defined on Uniqueidentifier datatype is a good candidate for the clustered index or otherwise.

View 1 Replies View Related

Non Clustered Index

Jun 29, 2007

Hi,
Is it advisable to create a Non Clustered Index in "ALLow NULL" column?



Thanks,
Rahul Jha

View 4 Replies View Related

Non Clustered Index

Nov 11, 2012

In Microsoft SQL Management Studio 2005 I have the ability to add a single non clustered index on a table on multiple columns (ordered how I want) AND/OR I may create a multiple of these non-clustered Index entries with a single column per non-clustered index.

Is there a difference between to two options? If yes, how do these options work differently? I assume option 1 is just a faster way of creating the non-clustered index and there is no architectural difference!?

View 2 Replies View Related

Clustered Index

Apr 13, 2008

Why can we have only one clustered index per table

View 4 Replies View Related

What Is Clustered Index A And B

Oct 20, 2014

what is clustered index A and B.

View 4 Replies View Related

Clustered Index And PK

Jan 14, 2007

Hi,

I have a table which I would like to index.
The table holds info of nurses:
T_NURSE=(NurseCode, LName, FName, IDNumber ...)
NurseCode => PK+Identity


Since queries will be on LName (and optionally on FName and IDNumber) I created a clustered index with this order: {LName, FName, IDNumber, NurseCode}

Questions:
1.Is it ok to have the clustered index not the PK?
2.If yes - what importance does the PK have here?
Looking for a nurse via screen (using:LName,FName,ID) or via source-code (using:NurseCode) is 50%/50%.
Which field(s) should have the honor of being a PK?
3.If I perform the search using a view (SELECT * FROM vw_Nurse) will it use the index?

Thanks,
Izik

View 11 Replies View Related

What Do You Mean 'clustered' Index?

Jul 17, 2006

A lot of detailed discussion explains the difference between clusteredand non-clustered indexes. But very few 'clarifies' why the term usedis 'clustered'. Well, once and for all, this is my take.*** The 'CLUSTERED' adjective refers to the INDEX being clustered (setadjacent) to the DATA.This means if you found the index, the data is already there beside it(you don't have to look anywhere else). From this note, everythinghopefully becomes clearer to you. (You can now read further in the techbook :-).So, the next time you are asked to explain what is a clustered (ornon-clustered ) index think of the above.

View 1 Replies View Related

Will Non-clustered INDEX Really Help!!!

Sep 28, 2006

Hi,

I have a table Student with N number of columns.
One of the column (int) is flgActive - which currently holds only 2 values either 0 / 1.

Depending on the operation I want do - I either include the where clause flgActive = 0 or flgActive = 1 in my queries. Basically I either fetch non-active students or active students.

Whenever I need to turn a student to Nonactive - flgactive column is updated to 0.

Will a non clustered index on flgActive column help in my querying - when all the records in the table is going to contain only 2 different values. (Assume that the student table holds abt 2 Million records with about 30% of the students nonactive.)

Thanks,
Loonysan

View 6 Replies View Related

Clustered Index Increment

Aug 20, 2004

I have a clustered index (Group_ID, Member_ID)
How do I set Member_ID to be an autoincrement field ( each should start at 1 for each Group_ID).

Can SQL Server autoincrement feature do this?

If not is the best way then use a stored procedure to get the max member_ID for that Group, increment it with 1 and the assign it to the new member_ID?

View 3 Replies View Related

Clustered Index Problem

Feb 6, 2006

does putting clustered index makes records physically ordered and grouped??

View 2 Replies View Related

Clustered Index Fill

Nov 6, 2001

I am a little confused about what fill factor to use in creating a clustered index on one of our major tables.
This table has about 4.5 million rows and currently there are 14 indexes associated with it, but no clustered index.
I want to create a clustered index (on datestamp )on this table, but cannot really grasp what fillfactor I should use.
The main use of this table is in daterange reporting.
No deletes are applied to this table(except archiving on an annual basis).
It grows by about 5 000 rows daily.
From what I have read in BOL, a high fillfactor(100) is only applicable for a read only table, and I feel that at the time of creating a clustered index on this table, it is readonly, cos the data will never need to be reorganised to insert a new row into it, only at end.
BOL states that a low fillfactor could degrade database read performance,
and where the vast majority of our processing(reporting) hits this table,that is a major concern.
BUT BOL also says that a low Fillfactor is recommended where there are changes to the data.
Space is obviously important, but access speed is overwhelmingly more important.
Should I use a fillfactor of 70/80/90 etc. Any help would be appreciated

View 2 Replies View Related

Non Clustered Index Size

Aug 15, 2000

How much does a table increase(%)in size when a non clusterd index is added to a column in that table if the table has say 1000 records?
Thanks.

View 1 Replies View Related

Clustered Index On GUID

Dec 5, 2005

I have a 3rd party app which creates tables for developers. It uses a guid as the unique key which is indexed. However none of these indexes are clustered. I have hear both good and bad about clustering on a GUID. i can't change this design other than to make these indexes clustered. Any opinions?

View 2 Replies View Related

Clustered Index Performance

Nov 16, 1998

We run an order entry system, and as such our Order Detail table comprises
over half of the data in the system. This isn't gigantic, about 1.5
gigabytes, but our performance problems are centering on this table.

My question is, does it make a difference how selective the clustered index
is in terms of insert performance. Our clustered index is on item_id.
There are around 200 items that can be ordered. This is reasonable
selectivity, but still there will be many pages of rows all having the
same value for the clustered index. Is there a performance penalty for
SQL Server having to choose one of the pages to store a record? Does
anybody know how it chooses which page to store a record on in the situation
where there are multiple pages with the same index value for the clustered
index?

Thanks...
ben

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved