Closed blms closed 4 days ago
I’ve been working a bit more on the this problem today. Here are my findings:
Document.dating_set
, so it’s likely to be the culprit.exporter = AdminDocumentExporter(queryset=Document.objects.all())
for c in exporter.http_export_data_csv().streaming_content:
print(c)
dating_set
from prefetch_related
actually reduces the amount of memory used almost all the way back down: to 2.16 GB in the Django shell and 3.28 GB in the admin UI. I suspect this is because the prefetch caches everything in memory before executing the queries, intending to offload that chunk of the work from the Postgres server into the application server memory, but I don’t know for sure.It seems counterintuitive but… is the solution really just to remove the prefetching of dating_set
?
Additional info from RSK:
prep_index_chunk
for the metadata needed for prefetch.We also bumped the production server's memory up to 32GB so it's unlikely this will be reached again for a while. But still good to optimize. Moving to backlog for now.
@blms - Marina hasn't noticed this bug in a while, did it get resolved?
@richmanrachel Temporarily resolved—my comment from earlier:
We also bumped the production server's memory up to 32GB so it's unlikely this will be reached again for a while. But still good to optimize. Moving to backlog for now.
Maybe good for the icebox.
@blms solved this issue by bumping up memory, so I'm closing!
Marina, via Slack:
dev notes
psycopg2.DatabaseError: out of memory for query result