peewee

Generic peewee way to iterate over large result set is to use iterator() method or to use cursor
See the documentation

psycopg2 specific option is to use ServerSide


Inspect raw SQL generated by your query using query.sql(). See this and doc