Is there a preferred way? There are currently 1640 rows in the game table to go through and will be adding about 1200 every year.
SELECT `date` FROM `game` WHERE `date`<'2009-11-09' ORDER BY `date` DESC LIMIT 1;
0.0004 seconds
SELECT MAX(`date`) AS `date` FROM `game` WHERE `date`<'2009-11-09' LIMIT 1;
0.0006 seconds
The speeds were for the first time this ran. Each time after was 0.0002 for each.
mySQL:
Server: Localhost via UNIX socket
Server version: 5.1.37
PHP (shouldn’t be relevant):
5.x
Apply MySQL EXPLAIN and check the query plans. The second example may well have a cleaner plan, which is nice as it looks cleaner to my eye. (Once you remove the limit.)
A noddy test locally shows (no indexes).
Query 1:
Plan
Query 2:
Plan