News for hackers. Stuff that matters.
Re:Let Postgres Do the Work (2013) by rtpg on Saturday November 26, 2016 @11:30PM (#13047718)
This really sounds like you're having an issue linked to the ORM.

I don't know the Rails equivalent, but Django's ORM has a way of prefetching related fields on a model in a single query.

My bet is that your code wasn't 1 query, but actually 4000 * 240 queries, which will always take a while.

EDIT: I just saw in a sibling comment that the actual data fetching was only taking 30s. I imagine you were doing that part mostly right

There are no comments on this comment yet.