Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8110711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:50:59+00:00 2026-06-06T01:50:59+00:00

So I have a huge update where I have to insert around 40gb data

  • 0

So I have a huge update where I have to insert around 40gb data into an innodb table. Its taking quite a while, so Im wondering which method would be the fastest (and more importantly why, as I could just do a split test).

Method 1)

a) Insert all rows
b) create ALTER TABLE su_tmp_matches ADD PRIMARY KEY ( id )

Method 2)

a) ALTER TABLE su_tmp_matches ADD PRIMARY KEY ( id )
b) Insert all rows

Currently we are using method 1, but the step b) seems to take a shitload of time. So Im wondering if there is any implication of the size here (40gb – 5 million rows).

—- so I decided to test this as well —
Pretty quick brand new mysql server – loads and loads of ram, and fast ram, fast discs as well, and pretty tuned up (we have more than 5000 requests per second on one pieces):

1,6 mio rows / 6gb data:

81 seconds to “delete” a primary index

550 seconds to “add” a primary index (after data is added)

120 seconds to create a copy of the table with the primary index create BEFORE data insert

80 seconds to create a copy of the table without the primary index (which then is 550 seconds to create afterwards)

Seems pretty absurd – question is, if indexes are the same thing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:51:01+00:00Added an answer on June 6, 2026 at 1:51 am

    From the documentation :

    InnoDB does not have a special optimization for separate index
    creation the way the MyISAM storage engine does. Therefore, it does
    not pay to export and import the table and create indexes afterward.
    The fastest way to alter a table to InnoDB is to do the inserts
    directly to an InnoDB table.

    It seems to me that adding the constraint of unicity before the insert could only help the engine if your column having a primary key is an autoincremented integer. But I really doubt there would be a notable difference.

    A useful recommendation :

    During the conversion of big tables, increase the size of the InnoDB
    buffer pool to reduce disk I/O, to a maximum of 80% of physical
    memory. You can also increase the sizes of the InnoDB log files.

    EDIT : as by experience MySQL doesn’t always perform as expected from the documentation performance-wise, I think any benchmark you do on this would be interesting, even if not a definite answer per se.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to update different server data which takes huge time. I have to
I have huge amount of data from database, i need to get or store
I have huge data which is static. I need to save it within the
I have huge amont of geographic data represented in simple object structure consisting only
I have a huge XML document 200MB in size containing textual information. The data
I have a huge database that is meant to be indexed, into which I
I have a huge table containing 161 million rows. The table structure is entryid(varchar),
we have a .NET 3.5 WinForms app that uses Linq2Sql to insert records into
We are using mysql. We have a huge table which contains 1 billion rows.
I have a fairly huge database with a master table with a single column

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.