I don't think there is a more efficient way to iterate over a resultset. Have you checked how fast the query actually runs, e.g. in SQLDeveloper or some other database tool? My assumption is, that the table is not indexed or some other performance bottleneck on the database end exists.