Answer the question
In order to leave comments, you need to log in
Why is there a different query execution plan for the same tables and configs?
There are two servers:
SELECT br.id, br.slug, br.name, br.location, br.postal_code, br.phone, br.branch_deposit, br.established,
br.working_hours, br.is_published, br.created_at, br.updated_at, c.id, c.name, c.slug, s.id, s.name, s.slug,
s.ansi_code
FROM branch AS br
JOIN city AS c ON c.id = br.city_id
JOIN state AS s ON s.id = c.state_id
WHERE br.bank_id = ? ORDER BY br.branch_deposit DESC LIMIT 10
SELECT STRAIGHT_JOIN br.id, br.slug, br.name, br.location, br.postal_code, br.phone, br.branch_deposit, br.established, br.working_hours, br.is_published, br.created_at, br.updated_at, c.id, c.name, c.slug, s.id, s.name, s.slug, s.ansi_code
FROM branch AS br FORCE INDEX(bank_id_branch_deposit)
JOIN city AS c FORCE INDEX(PRIMARY) ON c.id = br.city_id
JOIN state AS s ON s.id = c.state_id
WHERE br.bank_id = ?
ORDER BY br.branch_deposit DESC
LIMIT 10
Answer the question
In order to leave comments, you need to log in
Use EXPLAIN/MySQL Profiler to see the order in which a query is executed. Index values can be different.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question