Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to make this query run faster? Table contains over 2 million rows of data and takes around 30 to 120 seconds to process the query.

FROM blocks
  JOIN locations
  ON blocks.locId = locations.locId
LIMIT 0, 10

migration rejected from Apr 29 '14 at 15:44

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as too broad by ypercubeᵀᴹ, Paul White, RolandoMySQLDBA, Mark Storey-Smith, Max Vernon Apr 29 '14 at 15:44

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

Run an explain and go from there. – Mike B Mar 27 '14 at 19:20
Do your tables have indexes? Is caching a possibility? – rednaw Mar 27 '14 at 19:20
If you want us to help optimize a query, you need to show us the table and index definitions, as well as row counts for each of the tables. Maybe your tables are defined poorly. Maybe the indexes aren't created correctly. Maybe you don't have an index on that column you thought you did. Without seeing the table and index definitions, we can't tell. We also need row counts because that can affect query optimization greatly. If you know how to do an EXPLAIN or get an execution plan, put the results in the question as well. If you have no indexes, visit ASAP. – Andy Lester Mar 27 '14 at 20:41