Don't use DatabaseConnection::exec_SELECTgetRows()
The TYPO3 database API method
DatabaseConnection::exec_SELECTgetRows() should be avoided if the number of rows to fetch is unknown and/or not limited. Otherwise e.g. given there are 100000 rows, this call will fetch all of them at once and thus eat up a considerable amount of memory.
DatabaseConnection::sql_fetch_assoc() should be used instead to fetch rows one by one. Personally I'd recommend
DatabaseConnection::prepare_SELECTquery() though since it uses a prepared statement (and is thus safe from SQL injection) and allows for a rather simple usage.