DROP TABLE IF EXISTS ranges;
CREATE TABLE ranges (
id INT PRIMARY KEY,
start DATE,
end DATE,
UNIQUE KEY range_key(start, end)
);
INSERT INTO ranges VALUES (1, "2012-10-25", "9999-12-31");
INSERT INTO ranges VALUES (2, "1000-01-02", "2012-10-05");
INSERT INTO ranges VALUES (3, "9999-12-31", "1000-01-02");
INSERT INTO ranges VALUES (4, "1000-01-02", "9999-12-31");
SELECT * FROM ranges FORCE INDEX(range_key)
ORDER BY start, end;
id	start	end
2	1000-01-02	2012-10-05
4	1000-01-02	9999-12-31
1	2012-10-25	9999-12-31
3	9999-12-31	1000-01-02
DROP TABLE ranges;
