From http://stackoverflow.com/questions/1410048/how-to-select-first-n-records-from-a-database-containing-million-records