B
B
Bjornie2018-06-18 10:33:52
PostgreSQL
Bjornie, 2018-06-18 10:33:52

Why is loading slow or nginx 502 error after loaddata in Django?

Droplet DigitalOcena with 512mb RAM. To synchronize the database, I performed the following operation: I cleared the current psql database and filled in the json dump into the empty PostgreSQL database. The integrity of the base, everything is fine, but one app (and the main one, in which there are a lot of FKs) takes an incredibly long time to open, or after a timeout it gives an error 502 or 504.
I still don’t understand what could be the reason and where to look for it? With the previous base everything worked fine. No other operations were carried out. Googled a little and found something about vacuum.
Memory free about 100MB. CPU at idle 0-3%, with a simple visit, the load increases to 100%.
PS application for internal use, there are no visitors on it.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2018-06-18
@sergey-gornostaev

Run psql, enable timing, and try to run the same query as Django does. If it is slow, run the same query with explain analyze and see what takes the time. I suspect that the indexes are not built.

R
Roman Kitaev, 2018-06-18
@deliro

I bet you have N+1 requests there. See requests with django-debug-toolbar

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question