An additional `if (m_nret <= 0  || count < m_nret) m_nret = min(count, 1024);` should limit the amount of results per chunk here.