Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

index; insertion of data?

Status
Not open for further replies.

dodge20

MIS
Jan 15, 2003
1,048
US
I was wondering if it was better to create indexes after insert data into a new table, or is it better to create the indexes then insert the data. I thought I hear it was the first, but if anyone knows for sure I would appreciate any info.

Dodge20
 
I don't know which database your are working with, or what your application requirements are.

But, normally, you would thoroughly design your database before using it. Indexes are integral parts of your database and are designed with the rest of the database.

Dimandja
 
I know that, I already have the table designs planned out, I just wanted to know if it was better to add the indexes to the tables before or after I insert the data.

Dodge20
 
I was reading a humongous thread about MySQL a while ago and they mentioned that setting a field to index AFTER a bulk insert was substantially faster, like 30 mins vs. many hours. So yes, there is some credence to your idea. If you're not worried how long the insert will take, then just go the simple route and have the index in place, even if it takes 5X as long.
 
Insert data then make index is more, more faster than vice versa in all cases. Build B-tree (common index form with some variations) from scratch in indexing DBMS module is a very simple work. Add entry by entry (and rebuild index B-tree) in usual mode with implicit locking and other transaction processing on every step - nughtmare. Use 1st method when it's possible.
 

Yes, this is what I have always found...and heard.
With bulk insertions, the index gets rebuilt after each INDIVIDUAL insertion.
 
Thank you,

That is what I wanted to know.

Dodge20
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top