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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:27:36+00:00 2026-05-21T15:27:36+00:00

MySQL 5.1, Ubuntu 10.10 64bit, Linode virtual machine. All tables are InnoDB . One

  • 0

MySQL 5.1, Ubuntu 10.10 64bit, Linode virtual machine.

All tables are InnoDB.

One of our production machines uses a MySQL database containing 31 related tables. In one table, there is a field containing display values that may change several times per day, depending on conditions.

These changes to the display values are applied lazily throughout the day during usage hours. A script periodically runs and checks a few inexpensive conditions that may cause a change, and updates the display value if a condition is met. However, this lazy method doesn’t catch all posible scenarios in which the display value should be updated, in order to keep background process load to a minimum during working hours.

Once per night, a script purges all display values stored in the table and recalculates them all, thereby catching all possible changes. This is a much more expensive operation.

This has all been running consistently for about 6 months. Suddenly, 3 days ago, the run time of the nightly script went from an average of 40 seconds to 11 minutes.

The overall proportions on the stored data have not changed in a significant way.

I have investigated as best I can, and the part of the script that is suddenly running slower is the last update statement that writes the new display values. It is executed once per row, given the (INT(11)) id of the row and the new display value (also an INT).

update `table` set `display_value` = ? where `id` = ?

The funny thing is, that the purge of all the previous values is executed as:

update `table` set `display_value` = null

And this statement still runs at the same speed as always.

The display_value field is not indexed. id is the primary key. There are 4 other foreign keys in table that are not modified at any point during execution.

And the final curve ball: If I dump this schema to a test VM, and execute the same script it runs in 40 seconds not 11 minutes. I have not attempted to rebuild the schema on the production machine, as that’s simply not a long term solution and I want to understand what’s happening here.

Is something off with my indexes? Do they get cruft in them after thousands of updates on the same rows?


Update

I was able to completely resolve this problem by running optimize on the schema. Since InnoDB doesn’t support optimize, this forced a rebuild, and resolved the issue. Perhaps I had a corrupted index?

mysqlcheck -A -o -u <user> -p
  • 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-21T15:27:37+00:00Added an answer on May 21, 2026 at 3:27 pm

    There is a chance the the UPDATE statement won’t use an index on id, however, it’s very improbable (if possible at all) for a query like yours.

    Is there a chance your table are locked by a long-running concurrent query / DML? Which engine does the table use?

    Also, updating the table record-by-record is not efficient. You can load your values into a temporary table in a bulk manner and update the main table with a single command:

    CREATE TEMPORARY TABLE tmp_display_values (id INT NOT NULL PRIMARY KEY, new_display_value INT);
    
    INSERT
    INTO    tmp_display_values
    VALUES
    (?, ?),
    (?, ?),
    …;
    
    UPDATE  `table` dv
    JOIN    tmp_display_values t
    ON      dv.id = t.id
    SET     dv.new_display_value = t.new_display_value;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a (local) database (MySQL 5.1 at Ubuntu 10.10) with some 15000 tables
I have a (local) database (MySQL 5.1 at Ubuntu 10.10) with some 15000 tables
I can access my MySQL server on my remote Ubuntu 10.04 machine downstairs (local
I have mySQL database that I see form my Ubuntu shell, I want to
I need to query a Mysql database with Python. I have virtual env installed
I'm completely new to ubuntu and MySQL and I created a new database via:
Getting this error on issue mysql command on Ubuntu machine: ERROR 2002 (HY000): Can't
Can MySql 5.0 views use tables that are located on another server? What is
I have a new Ubuntu Linux Server 64bit 10.04 LTS. A default install of
I have a MySql table whose primary key is a 64bit BigInt I'm using

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.