I typically run my test suites on an in-memory SQLite3 DB. However, I have some projects that absolutely require postgres and raise exceptions with SQLite3. In these cases, how can I improve speed?
I have one test config that runs in 2.97s in sqlite vs. 89.71s in postgres. I mean that's crazy.
I have turned fsync off in postgres - that got me from 101.59s to 89.71s.
Your server configuration can certainly have an impact on this speed and turning fsync off will make the table creation faster which is a big part of the initial start up cost.
Another part of this is how Django handles fixtures which can seriously hurt performance if you have a large number of fixtures. Django loads fixtures and rolls back the transaction for each test method (not each test class). There is a third-party app django-fasttest which uses savepoints after the fixture loading to optimize this loading. django-nose has similar optimizations for re-using previously created databases and fixture bundling.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With