-- tested with MySQL 5.6 -- with combined index of timestamp and status EXPLAIN SELECT id, name, status, date FROM history WHERE timestamp = 1420934400 OR status = 3; -- with separated indexes for timestamp and status EXPLAIN SELECT id, name, status, date FROM history WHERE timestamp = 1420934400 OR status = 3;
id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | SIMPLE | history | null | ALL | test_idx | null | null | null | 1407 | 20.4 | Using where |
id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | SIMPLE | history | null | index_merge | status_idx,timestamp_idx,test_idx | timestamp_idx,status_idx | 4,4 | null | 255 | 100 | Using union(timestamp_idx,status_idx); Using where |