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 7905627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:33:29+00:00 2026-06-03T10:33:29+00:00

We’re using MySQL and have an ~1.1 million record InnoDB table where the entire

  • 0

We’re using MySQL and have an ~1.1 million record InnoDB table where the entire table has to be replaced with data from a CSV twice per day.

What I’ve been doing up until now is truncating the table, then using mysqlimport to repopulate the table from the fresh CSV twice a day. This results in around 160 seconds of downtime, which I was initially told was fine, but that is no longer the case.

The only way I can think of to do this is to have a staging table and a production table. Live queries will go to production, and when I need to repopulate the db, I’ll truncate staging, then mysqlimport the CSV into it, then after that is done I will swap the names so that staging will have the old database and production will contain the freshly imported CSV. I guess I would need an intermediate name, like production becomes production2, the staging becomes production, and then production2 becomes staging.

Does anyone have an alternate solution? The table needs to be imported as quickly as possible which is why I’m using mysqlimport, and the downtime must be extremely minimal.

  • 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-03T10:33:30+00:00Added an answer on June 3, 2026 at 10:33 am

    I think you already have the optimal solution. Just make sure you do an atomic rename, i.e. “rename table production to production2, staging to production”. This way it will be transparent to the application/users. One thing to watch out for is if there are foreign keys that reference this table, because the keys will still reference the renamed old table. But I guess since you are able to truncate it before without any issue, you don’t have any in place.

    EDIT: I’m quite new to commenting on StackOverflow so I don’t know if this is the best place to do so, but I just want to comment on the answer posted by eggyal – TRUNCATE causes an implicit commit so the proposed solution won’t work as described (i.e. the changes will be seen to the user/application even before the new data is loaded).

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

Sidebar

Related Questions

I am using jsonparser to parse data and images obtained from json response. When
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.