Server code takes more than 15 seconds to iterate over 1000 rows?

If you really need row id, you need to create your own row id since the system row_id must not be used: Short, Unique ID Values