Our Django tests are getting slow, and a lot of time is spend in cursor.execue()
.
There are roughly two ways now: Rewrite the tests to mock the ORM, or make PostgreSQL faster.
This question is about "make PostgreSQL faster".
What can I do to improve PostgreSQL speed if D (Durability) of ACID is not important. Everything could be kept in RAM.
Constraint: This question is about what you can do without modifying the Django/Python/SQL code.
Best Answer
use
UNLOGGED
tables throughoutset
shared_buffers
big enough to contain the whole databaseif you have bigger queries, increase
work_mem
have enough RAM to contain
shared_buffers
pluswork_mem
times the number of client connectionsTypically, you can gain most by tuning the queries that use most of the time.