Django ORM 使用游标来内存优化 QuerySets
Django ORM using cursor to memory optimize QuerySets
有什么方法可以说服 Django ORM 在遍历大型 QuerySet 时使用数据库游标,这样它就不会一次加载所有对象,而是分部分加载它们?
您可以将 .iterator()
用作 documented
Oracle and PostgreSQL use server-side cursors to stream results from
the database without loading the entire result set into memory.
有什么方法可以说服 Django ORM 在遍历大型 QuerySet 时使用数据库游标,这样它就不会一次加载所有对象,而是分部分加载它们?
您可以将 .iterator()
用作 documented
Oracle and PostgreSQL use server-side cursors to stream results from the database without loading the entire result set into memory.