SELECTing the top n elements from a table is easy:
SELECT id FROM pixels WHERE pixel_id='some_pixel_id' ORDER BY id DESC LIMIT 1000;
Finding the n-th element with a subquery is quite straightforward:
SELECT MIN(id) FROM
(SELECT id FROM pixels WHERE pixel_id='some_pixel_id' ORDER BY id DESC LIMIT 1000) s;
Assuming that there is a BTREE index on the relevant columns (id), is this approach efficient? Are there any better alternatives?