I have a huge database (some 33 millions rows).
Every X seconds a new row is added.
DATE_TIME is stored as primary key.
A progressive INDEX (unsigned int) is recorded. It grows only.
Of course DATE_TIME and INDEX are already sorted.
The full structure is:
DATE_TIME, INDEX, SOME_VAL1, SOME_VAL2
select FIRST(date_time), index, FIRST(some_val1), FIRST(some_val2) from YOURTABLE group by index