我的land_value
表(Postgres 10.5)有5M +行。我期望下面的代码返回从数据库收到的行,但是我什至没有得到for
循环中的第一行。
发生了什么事,该程序在下面的代码中永不超越rows = db.session.query(LandValue)
。看着htop
,python进程一直在消耗内存...它超越了16GB的物理内存,而虚拟内存则一直增长到25GB +。
根据我的研究,db.query().all()
会将所有行都放入ORM,但我正在执行db.query(),我相信应该将这些行流回。为什么这没有发生?
from models import *
from app import db, app, mail
if __name__ == '__main__':
rows = db.session.query(LandValue)
for row in rows:
print(row.prop_id)
其他有用信息: