SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


NON-Clustered Indexes on table but no Clustered Indexes


NON-Clustered Indexes on table but no Clustered Indexes

Author
Message
Mohit K. Gupta
Mohit K. Gupta
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1500 Visits: 1089
Thanks Gail.

I understand your points, I think the Microsoft consultant was just suggesting I should seriously look at the fields in questions because there is no doubt for room for improvement (might not be as significant as DMV suggests). I have never created indexes out blank from there; but it gives a "starting" point.

But I never thought about the cluster/non-clustered part heh, thanks for pointing that out. Most databases I have tuned I got clustered indexes fixed on them (so I thought); so I never even consider if the recommended index by DMV for Clustered. Or that I should look at revising clustered index based of that information.

I appreciate your view points Smile.

Thanks a lot.
Mohit.

---

Mohit K. Gupta, MCITP: Database Administrator (2005), My Blog, Twitter: @SQLCAN.
Microsoft FTE - SQL Server PFE

* Some time its the search that counts, not the finding...
* I didn't think so, but if I was wrong, I was wrong. I'd rather do something, and make a mistake than be frightened and be doing nothing. Smooooth


How to ask for help .. Read Best Practices here.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)

Group: General Forum Members
Points: 90799 Visits: 45284
Mohit (5/4/2009)
I understand your points, I think the Microsoft consultant was just suggesting I should seriously look at the fields in questions because there is no doubt for room for improvement (might not be as significant as DMV suggests). I have never created indexes out blank from there; but it gives a "starting" point.


Agreed. I just see too many people suggesting to generate create index statements from the missing index DMVs and simply run them.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Mikey01
Mikey01
SSC Veteran
SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)

Group: General Forum Members
Points: 204 Visits: 204
How does the DTA handle Temporary Tables.....

I was of teh opinion that the DTA was incappable of giving suggestions on Temporary tables is that incorrect?
Mikey01
Mikey01
SSC Veteran
SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)SSC Veteran (204 reputation)

Group: General Forum Members
Points: 204 Visits: 204
I realise I can use the DTA to analyse the Perm tables i've created I'm just wondering if i've wasted my time here potentially? i.e. could i have just used the DTA against teh Temp Tables...

Thansk for all the input here guys aswell
Bob Griffin
Bob Griffin
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1401 Visits: 702

Agreed. I just see too many people suggesting to generate create index statements from the missing index DMVs and simply run them.


Gail,
Do you have a general process you go through for adding indexes...is simply a matter of testing the indexes one at a time before implementing? Just curious.....

Thanks
GilaMonster
GilaMonster
SSC Guru
SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)SSC Guru (90K reputation)

Group: General Forum Members
Points: 90799 Visits: 45284
No formal process.

If I'm considering the indexes from missing indexes DMV, first I'll make sure there are no partial redundancies within the index recommendations. I'll also make sure that there are no existing indexes that I can widen.

Once that's done, I'll get all the queries that run against that table (from the metadata if all access is via SP, or from profiler if they're not), run them, get their current performance characteristics. Create the new index, or alter an existing one, run the queries again and see if there's been an improvement.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


jts2013
jts2013
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1288 Visits: 5009
Mohit K. Gupta (5/1/2009)
If you are just using non-clustered indexes and heap; it will first cause a RID Lookup anytime you access anything in that table via a Index Seek. That is when an index seek operation completes it will have to go back to main heap to get the data. In addition when you are inserting, deleting, and updating records in the table the heap can become fragmented and there is no way to defrag it because of how heap are stored. So the access speed, updates, and deletes can take long time.

Hi there, I have also found a large table with no clustered indexes and four non-clustred indexes. I can see that one of these non-clustered indexes is being used in the query, but I don't understand what happens then with the RID Lookup - since there is no clustered index does SQL Server have to scan the whole heap? In which case, why bother with an index at all! Hope I'm making sense :-) I'm thinking of adding a clustered index to the table, but it's from a 3rd party app, so I need to be very careful (i.e. break the test system first!).
Mohit K. Gupta
Mohit K. Gupta
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1500 Visits: 1089
JTS: RID Lookup is used to retrieve information from the table that is not part of the index. For example lets say you have a table with col1, col2, col3, col4. You have a non-clustered index on col1. You execute "Select * from Table1 Where Col1 = 123"; system will do a quick seek on col1 to get RID information for all the values in col1 where it is 123. Then using the RID information it will go to the heal to get the remaining information requested by the query, namely col2, col3, and col4. RID tells SQL Server where the row is physically located and for a singleton requests is fairly quick. However if you have scans or range retrieval of the information it can get expensive Smile.

Answer you question, should you add Clustered Index? Since this is a 3rd party application most likely not a good idea as most 3rd party vendors will void warranty if people change their database or application. So please take that into consideration. However define large table for me? If the table has more then 1000 pages, maybe look at considering a cluster index. Alternative you might be able to convert one of your non-clusters indexes to clustered. Test, test, and test... before you implement anything Smile.

Cheers!

---

Mohit K. Gupta, MCITP: Database Administrator (2005), My Blog, Twitter: @SQLCAN.
Microsoft FTE - SQL Server PFE

* Some time its the search that counts, not the finding...
* I didn't think so, but if I was wrong, I was wrong. I'd rather do something, and make a mistake than be frightened and be doing nothing. Smooooth


How to ask for help .. Read Best Practices here.
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)

Group: General Forum Members
Points: 89927 Visits: 41146
Mikey01 (5/1/2009)
I should point out the process creates over 150 tables in total.... and is probably spread across a couple 100,000 lines of SQL & 250 stored procs


That seems a bit much even for a really complicated process. What does this process actually do?

My recommendation would be to forget about indexing for now. A whole lot of people think that Temp Tables and While Loops are somehow better than a cursor. Neither is acceptable and the number of Temp Tables and procs you've identified strongly indicates such RBAR. Start by checking to find out if the stored procs are set based or if they're only handling one agonizing row at a time.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
robpurrington
robpurrington
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 65
What about tables that don't have a unique value? How do I create a unique clustered index? Is that even possible without an identity of some sort? Can I make an index on a table that is non-unique clustered without making it a heap?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search