Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

NON-Clustered Indexes on table but no Clustered Indexes Expand / Collapse
Author
Message
Posted Monday, May 4, 2009 12:46 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Saturday, August 23, 2014 10:43 AM
Points: 942, Visits: 1,064
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 :).

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.


How to ask for help .. Read Best Practices here.
Post #709633
Posted Monday, May 4, 2009 1:43 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:37 PM
Points: 40,210, Visits: 36,619
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 2008, MVP
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

Post #709669
Posted Tuesday, May 5, 2009 7:00 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 5:47 AM
Points: 178, Visits: 187
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?
Post #710138
Posted Tuesday, May 5, 2009 7:07 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 5:47 AM
Points: 178, Visits: 187
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
Post #710145
Posted Thursday, May 7, 2009 8:05 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, October 20, 2014 6:48 PM
Points: 1,136, Visits: 699

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
Post #712047
Posted Thursday, May 7, 2009 9:33 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:37 PM
Points: 40,210, Visits: 36,619
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 2008, MVP
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

Post #712134
Posted Thursday, March 3, 2011 7:59 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, October 7, 2014 1:25 AM
Points: 1,105, Visits: 4,902
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!).
Post #1072577
Posted Saturday, March 5, 2011 9:13 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Saturday, August 23, 2014 10:43 AM
Points: 942, Visits: 1,064
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 :).

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 :).

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.


How to ask for help .. Read Best Practices here.
Post #1073710
Posted Saturday, March 5, 2011 10:52 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 4:17 PM
Points: 35,372, Visits: 31,920
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1073738
Posted Friday, August 22, 2014 1:18 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, August 25, 2014 4:30 PM
Points: 1, Visits: 7
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?
Post #1606483
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse