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

what is the difference if we create index (at time create table or after insert data into that table ?) Expand / Collapse
Author
Message
Posted Wednesday, March 26, 2014 12:30 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: 2 days ago @ 4:40 AM
Points: 998, Visits: 297
hi all,

can you explain me the effect of the below questions ?

what is the difference if we create index (at time create table or after insert data into that table ?)
Post #1554783
Posted Wednesday, March 26, 2014 12:34 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Sunday, November 23, 2014 4:20 AM
Points: 215, Visits: 877
Sounds like someone's homework. What do you think the answer is?
Post #1554784
Posted Wednesday, March 26, 2014 12:57 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 21, 2014 2:56 AM
Points: 2,603, Visits: 2,061
It depends. What is the size of data?

---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
Post #1554792
Posted Wednesday, March 26, 2014 4:48 PM


SSC-Dedicated

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

Group: General Forum Members
Last Login: Yesterday @ 8:55 PM
Points: 35,618, Visits: 32,214
Heh... I'll second the "It Depends" aspect.

What Recovery Model is the database in?
What kind of index are you trying to build?
How many rows are you inserting in the initial batch of rows?


--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 #1555215
Posted Thursday, March 27, 2014 12:05 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Monday, November 24, 2014 5:46 AM
Points: 3,998, Visits: 7,172
+1 Jeff

Ultimately you need to test and get an idea of when it's quicker. It often does depend on how much data, and your disk I/O. Are you creating a temp table and creating the index afterwards (i.e on the fly) or are you referring to a "typical" table that could have millions of rows over time?


______________________________________________________________________________
"Never argue with an idiot; They'll drag you down to their level and beat you with experience"
Post #1555275
Posted Thursday, March 27, 2014 12:37 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 21, 2014 2:56 AM
Points: 2,603, Visits: 2,061
kbhanu15 (3/26/2014)

what is the difference if we create index (at time create table or after insert data into that table ?)

Is this interview question?


---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
Post #1555281
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse