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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:59:01+00:00 2026-05-17T20:59:01+00:00

lets assume you have a table with 1M rows and growing … every five

  • 0
  • lets assume you have a table with 1M rows and growing …
  • every five minutes of every day you run a python programm which have to update some fields of 50K rows

my question is: what is the fastest way to do the work?

  • runs those updates in loop and after last one is executed than fire up a cursor commit?
  • or generate file and than run it throught command line?
  • create temp table by huge and fast insert and than run a single update to production table?
  • do prepared statements?
  • split it up to 1K updates per execute, to generate smaller logs files?
  • turn off logging while running update?
  • or do a cases in mysql examples (but this works only up to 255 rows)

i dont know … have anyone do something like this? what is the best practise? i need to run it as fast as possible …

  • 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-05-17T20:59:02+00:00Added an answer on May 17, 2026 at 8:59 pm

    Here’s some ways you could speed up your UPDATES.

    When you UPDATE, the table records are just being rewritten with new data. And all this must be done again on INSERT. That’s why you should always use INSERT ... ON DUPLICATE KEY UPDATE instead of REPLACE.

    The former one is an UPDATE operation in case of a key violation, while the latter one is DELETE / INSERT

    Here’s an example INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1; More on this here.

    UPDATE1: It’s a good idea to do your inserts all in a single query. This should speed up your UPDATES. See here on how to do that.

    UPDATE2: Now that I have had a chance to read your other sub-questions. Here’s what I know-

    • instead of in a loop, try to execute all UPDATE in a single sql & single commit.
    • Not sure this is going to make any difference. SQL queries are more important.
    • Now this is something you could experiment with. Benchmark it. This kind of a thing depends on the size of the TABLE & the INDEXES you have, plus INNODB or MYISAM.
    • No idea about this.
    • refer first point.
    • Yes, this might speed your stuff up slightly. Also see if you have slow_query_log turned on. This logs all slow queries to a separate logfile. Turn this off too.
    • Again. refer first point.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a table with a lot of cells, lets assume 50 rows
(code examples are python) Lets assume we have a list of percentages that add
Let's assume you have a table and the following Jquery code var rows =
Let's assume I have a table full of teachers . every teacher has these
Lets assume we have this xml: <?xml version=1.0 encoding=UTF-8?> <tns:RegistryResponse status=urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure xmlns:tns=urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0 xmlns:rim=urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0> <tns:RegistryErrorList
Let's assume I have three table - list , a and b table list
Let's assume I have a model called product. Let's assume that product has three
Or vice versa. Update: Hmm, let's assume I have a shopping cart app, the
Lets assume my classes are loaded from a compressed .war file or loaded elsewhere,
Lets assume that I'm dealing with a service that involves sending large amounts of

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.