January 3, 2008 at 6:01 pm
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.
January 3, 2008 at 7:25 pm
Did you use Clustered or Non-Clustered?
--Jeff Moden
Change is inevitable... Change for the better is not.
January 3, 2008 at 7:49 pm
In any case, I need to add clustered index as well as non-clustered index in sample large table.
January 3, 2008 at 9:59 pm
Considering that a clustered index will dictate the physical order in which data is stored in the table, creating a clustered index will likely take a while with 10 Million rows. I'm not sure how much data you have - but on a busy server 10 minutes might not be entirely out of the question.
If you need to build both a clustered and a non-clustered index, build the clustered index first, since the NCI stores the keys from the clustered index to know how to get to the records. Building the non-clustered index first will only cause it to be rebuilt once you create the clustered index.
It might not be fast, since it sounds like it will rearrange all of that data, but that usually should be your order of attack.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
January 4, 2008 at 7:47 am
Next question:
Should I use script like below (Query Analyzer ) or use SQL Server 7 Enterprise Manager and do table design option? Which one is faster?
CREATE CLUSTERED INDEX TblPartBit_CustomerID_IDX
ON TblPartBit (tableID)
GO
thanks
January 4, 2008 at 7:57 am
Both will take the same time because EM7 will run the same code as what you've typed behind the scenes...
--Jeff Moden
Change is inevitable... Change for the better is not.
January 4, 2008 at 8:14 am
Use query analyser. While they run the same code, if the operation takes too long, enterprise manager may timeout and undo the operation. Query analyser doesn't timeout.
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
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply