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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:47:21+00:00 2026-06-17T22:47:21+00:00

I’m working on optimizing a MySQL query, but am running into a strange issue.

  • 0

I’m working on optimizing a MySQL query, but am running into a strange issue. I never work with the live production database, so I create a dump of it and import it into a database on my local machine using mysqldump with no extra options.

The versions of mysql on the production database and my local virtual machine are nearly exactly the same:

Production:
mysql Ver 14.14 Distrib 5.1.61, for debian-linux-gnu (x86_64) using readline 6.2

Virtual Machine:
mysql Ver 14.14 Distrib 5.1.63, for debian-linux-gnu (x86_64) using readline 6.2

This one query is pretty complicated and takes around 4-5 seconds on production, but takes less than 1 second on the VM. The only thing I can think of is that maybe there are locks on the production database that prevent the query from running right away, and the query must wait on the locks?

The EXTENDED EXPLAIN when running the query against each database is nearly the same, with a couple slight differences.

I’m using SQL_NO_CACHE before the query to ensure the queries are not hitting the cache.

So my questions are:

  1. What could cause EXTENDED EXPLAIN to differ, even slightly, when I’m working with a copy of the production database, and the mysql versions are the same?
  2. Is there any reason that I’m not thinking of that would cause the same query to take longer on the production database?
  • 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-17T22:47:22+00:00Added an answer on June 17, 2026 at 10:47 pm

    There’s a number of things that could affect this execution time:

    What is the loading like on your production system? How much IO headroom do you have? If your system is busy running other queries or doing heavy IO, the performance of any query will suffer severely.

    Generally you can use SHOW PROCESSLIST to help identify what’s currently running and a program like iotop to see how much IO is going on.

    Is your virtual machine running off of SSD? Even a mid-range development machine with SSD will blow away nearly any HD based database server for anything that’s heavily dependent on random access.

    Have you ever tried OPTIMIZE TABLE on the production system? When you do a restore the table is always optimized automatically. On a live system the table will slowly degrade as you INSERT and DELETE rows.

    Make sure both are using the same storage engine. MyISAM is often faster than InnoDB but isn’t safe to use in a production environment for critical data. Check with SHOW TABLE STATUS to see what engine is used for each table. You may have different defaults.

    Also check that /etc/my.cnf is tuned accordingly. The default configuration for MySQL is terrible. You really need to allocate more memory for InnoDB buffers or performance will be awful.

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I am currently running into a problem where an element is coming back from
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I've tracked down a weird MySQL problem to the two different ways I was
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

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.