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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:52:34+00:00 2026-05-14T03:52:34+00:00

I could try to post and explain the exact query I’m trying to run,

  • 0

I could try to post and explain the exact query I’m trying to run, but I’m going by the old adage of, “give a man a fish and he’ll eat for a day, teach a man to fish and he’ll eat for the rest of his life.” SQL optimization seems to be very query-specific, and even if you could solve this one particular query for me, I’m going to have to write many more queries in the future, and I’d like to be educated on how indexes work in general.

Still, here’s a quick description of my current problem. I have a query that joins three tables and runs in 0.2 seconds flat. Awesome. I add an “order by” clause and it runs in 4 minutes and 30 seconds. Sucky. I denormalize one table so there is one fewer join, add indexes everywhere, and now the query runs in… 20 minutes. What the hell? Finally, I don’t use a join at all, but rather a subquery with “where id in (…) order by” and now it runs in 1.5 seconds. Pretty decent. What in God’s name is going on? I feel like if I actually understood what indexes were doing I could write some really good SQL.

Anybody know some good tutorials? Thanks!

  • 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-14T03:52:34+00:00Added an answer on May 14, 2026 at 3:52 am

    Not a very riveting answer, but I’ve found the official docs to give good background:

    http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html

    A few things you could try (assuming you’ve already analysed the optimizer path with EXPLAIN):

    • Try running the query with USE INDEX
      (<your index name here>)
      to see if
      your index usage would actually
      provide the performance you expect.
    • Make sure the order of your columns
      in any composite index reflects the
      way you expect that index to be used
      (sorry if that’s a bit vague, but
      MySql index usage can be a bit quirky
      at times).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote out a long post trying to explain the exact details of the
When I try to run rails server on a new project it returns Could
I would try it myself, but I can't. Could someone check for me? I
When I try to run this code, I get incorrect maximums and minimums. Could
I really didn't know what title to give this question, but I'll explain here:
This is my first post here and my first try to explain a coding
I try to use Spring to develop liferay portlets (version 6.0.6), could i use
I could not find a clear answer to this question elsewhere, so I'll try
I hope you could help me. I' m using QT and try to do
I have a strange problem that I could not solve. When I try to

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.