Hi,
MySQL Version: 5.1.52-community-log
InnoDB Version: 1.0.13
I have two identical servers (cpu/mem/disk/my.cnf) with identical databases.
Both these servers are read-only slaves of the same master database server, which means they both use InnoDB and both have exactly the same data, indexes, column definitions etc.
The issue I find is that each of them have a different query execution plan for the same query, can anyone explain this? This is the query:
EXPLAIN SELECT f.hightemp, f.forecast
FROM forecast f JOIN place p ON f.placeID = p.placeID
WHERE p.countryid = 64
AND f.fctypeID = 7
AND date(f.timestamp) = current_date
AND p.place = 'auckland'
ORDER BY f.forecastID DESC
LIMIT 1;
Server1:
+----+-------------+-------+--------+--------------------------------------------+-----------------------+---------+-------------------+--------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+--------+--------------------------------------------+-----------------------+---------+-------------------+--------+-------------+
| 1 | SIMPLE | f | ref | idx_forecast_fctypeID,idx_forecast_placeID | idx_forecast_fctypeID | 5 | const | 592466 | Using where |
| 1 | SIMPLE | p | eq_ref | PRIMARY,idx_forecast_countryid | PRIMARY | 4 | weather.f.placeID | 1 | Using where |
+----+-------------+-------+--------+--------------------------------------------+-----------------------+---------+-------------------+--------+-------------+
Server2:
+----+-------------+-------+------+--------------------------------------------+------------------------+---------+-------------------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+--------------------------------------------+------------------------+---------+-------------------+------+----------------------------------------------+
| 1 | SIMPLE | p | ref | PRIMARY,idx_forecast_countryid | idx_forecast_countryid | 5 | const | 102 | Using where; Using temporary; Using filesort |
| 1 | SIMPLE | f | ref | idx_forecast_fctypeID,idx_forecast_placeID | idx_forecast_placeID | 5 | weather.p.placeID | 3142 | Using where |
+----+-------------+-------+------+--------------------------------------------+------------------------+---------+-------------------+------+----------------------------------------------+
Does anyone have an idea why this would happen?
Thanks
Clive
MySQL Version: 5.1.52-community-log
InnoDB Version: 1.0.13
I have two identical servers (cpu/mem/disk/my.cnf) with identical databases.
Both these servers are read-only slaves of the same master database server, which means they both use InnoDB and both have exactly the same data, indexes, column definitions etc.
The issue I find is that each of them have a different query execution plan for the same query, can anyone explain this? This is the query:
EXPLAIN SELECT f.hightemp, f.forecast
FROM forecast f JOIN place p ON f.placeID = p.placeID
WHERE p.countryid = 64
AND f.fctypeID = 7
AND date(f.timestamp) = current_date
AND p.place = 'auckland'
ORDER BY f.forecastID DESC
LIMIT 1;
Server1:
+----+-------------+-------+--------+--------------------------------------------+-----------------------+---------+-------------------+--------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+--------+--------------------------------------------+-----------------------+---------+-------------------+--------+-------------+
| 1 | SIMPLE | f | ref | idx_forecast_fctypeID,idx_forecast_placeID | idx_forecast_fctypeID | 5 | const | 592466 | Using where |
| 1 | SIMPLE | p | eq_ref | PRIMARY,idx_forecast_countryid | PRIMARY | 4 | weather.f.placeID | 1 | Using where |
+----+-------------+-------+--------+--------------------------------------------+-----------------------+---------+-------------------+--------+-------------+
Server2:
+----+-------------+-------+------+--------------------------------------------+------------------------+---------+-------------------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+--------------------------------------------+------------------------+---------+-------------------+------+----------------------------------------------+
| 1 | SIMPLE | p | ref | PRIMARY,idx_forecast_countryid | idx_forecast_countryid | 5 | const | 102 | Using where; Using temporary; Using filesort |
| 1 | SIMPLE | f | ref | idx_forecast_fctypeID,idx_forecast_placeID | idx_forecast_placeID | 5 | weather.p.placeID | 3142 | Using where |
+----+-------------+-------+------+--------------------------------------------+------------------------+---------+-------------------+------+----------------------------------------------+
Does anyone have an idea why this would happen?
Thanks
Clive