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

  • Home
  • SEARCH
  • 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 6065957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:26:57+00:00 2026-05-23T09:26:57+00:00

I have a table with almost 1 million records and another table with a

  • 0

I have a table with almost 1 million records and another table with a few hundred records. I would like to update the large table with values from the small table with the following

UPDATE tableA ta, tableB tb
SET price=tb.price
WHERE ta.id=tb.id

Using the above SQL statement, the query is taking a really long time (more than 1 hour). Is there a method that I can use to make this operation faster?

Here is the schema for both tables.

Table A

id         name   descrip   region   price
0          a      abc       def      1.7
1          b      abc       def      2.2
3          c      abc       def      3.4
4          d      abc       def      5.3
....       .      ...       ...      ...
999999     e      abc       def      4.5
1000000    f      abc       def      7.9

Table B

id      price
0       0.7
1       2.5
3       1.9
4       7.9

Result
Table A

Table A

id         name   descrip   region   price
0          a      abc       def      0.7
1          b      abc       def      2.5
3          c      abc       def      1.9
4          d      abc       def      7.9
....       .      ...       ...      ...
999999     e      abc       def      4.5
1000000    f      abc       def      7.9
  • 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-23T09:26:58+00:00Added an answer on May 23, 2026 at 9:26 am

    If your tableB has index, that covers id (obviously it is) – then you have no other ways to speed it up. Since the slowest thing here is physical changing of the value.

    Probably you can change your where to:

    WHERE ta.id=tb.id and ta.price <> tb.price
    

    to avoid of updating the price to the same value

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

Sidebar

Related Questions

I have a table watchlist containing today almost 3Mil records. mysql> select count(*) from
We have a large table in SQL Server with almost 40.000.000 records. it took
I have a table with almost 800,000 records and I am currently using dynamic
I have been building index on a 200 million row table for almost 14
I have a table DEAL and a table DEAL_TYPE. I would like to map
Background: I have a table with 5 million address entries which I'd like to
I have a table message in a database that has almost a million rows.
I have 400 million tweets ( actually I think its almost like 450 but
I have a large MySQL table (about 750 million rows) and I just want
Simple situation. I have a list of lists, almost table like, and I am

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.