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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:51:08+00:00 2026-05-14T01:51:08+00:00

There’s this already populated database which came from another dev. I’m not sure what

  • 0

There’s this already populated database which came from another dev.

I’m not sure what went on in that dev’s mind when he created the tables, but on one of our scripts there is this query involving 4 tables and it runs super slow.

    SELECT 
       a.col_1, a.col_2, a.col_3, a.col_4, a.col_5, a.col_6, a.col_7
    FROM
       a, b, c, d 
    WHERE
       a.id = b.id
   AND b.c_id = c.id
   AND c.id = d.c_id
   AND a.col_8 = '$col_8'
   AND d.g_id = '$g_id'
   AND c.private = '1'

NOTE: $col_8 and $g_id are variables from a form

It’s only my theory that it’s due to tables b and c not having an index, although I’m guessing that the dev didn’t think that it was necessary since those tables only tell relations between a and d, where b tells that the data in a belongs to a certain user, and c tells that the user belongs to a group in d.

As you can see, there’s not even a join or other extensive query functions used but this query which returns only around 100 rows takes 2 minutes to execute.

Anyway, my question is simply this post’s title. Will a mysql query run slower if one of the tables involved has no index defined?

  • 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-14T01:51:08+00:00Added an answer on May 14, 2026 at 1:51 am

    YES! It will be MUCH slower.

    You need to put indices on all the “IDs”.

    And probably should rewrite the query to use joins (will help the optimizer)…

    Just after putting the indices there you can see hundred times performance increase.

    The other thing that such a query says is that the previous developer was “A complete idiot ™”

    M.

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

Sidebar

Related Questions

There is a conversion process that is needed when migrating Visual Studio 2005 web
There is previous little on the google on this subject other than people asking
There are numerous Agile software development methods. Which ones have you used in practice
There is a field in my company's Contacts table. In that table, there is
For some reason, after submitting a string like this Jack’s Spindle from a text
I have text I am displaying in SIlverlight that is coming from a CMS
There is any syntax to use something like this?: <?php function get_foo() { return
There is a container, for example lets say which has a volume of V.
There is a product which runs multiple reports to indicate the quality of different
There is a vim function Send_to_Screen(text) which sends some text to a console screen

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.