My new project (Relishment) is an opportunity for me to experiment with different technology. In this case I decided to switch to PostgreSQL from the RDMS I am familiar with MySQL.
So after struggling to learn the user management system in PostgreSQL, ”Ident authentication failed” was stumping me for a while, I finally got Django connected to a database. The next step was to run the test suite, and then wait.
And wait I did, what was a two or three second run on MySQL was a fifteen second run on PostgreSQL. Hardly desirable when I can run my tests up to several times a minute when debugging an issue. A quick poke around established it was “CREATE DATABASE” at the beginning of the test run that was eating all time.
Googling around the suggestions were that my shiny new Ubuntu 11.04 install, which uses the ext4 file system, is less than optimal for how PostgreSQL goes about things. It also turned up a solution, turning fsync off, which is dangerous on a live server but for development it doesn’t matter if you lose data in a crash.
The fix works splendidly, speeds at least matching MySQL, if not beating it.
DO NOT DO THIS ON A LIVE SERVER!!
So first you want to edit your PostgreSQL file:
Find this line:
And change it to this:
Save and close the config file and restart PostgreSQL:
And you should get a nice speed improvement when running your test cases.
I like your DO NOT DO THIS ON A LIVE SERVER warning. Very thoughtful.
I just wanted you to know that you’re not screaming into the night, don’t listen to li li.
p.s. your website is shiny, wish i had a nice shiny website like this one instead of my blogspot.
You sir, are a life saver. This performance problem was killing me on my dev server, tearing down and recreating many sites took forever. I knew the problem was with ext4, but had no clue how to fix it until your post. Thanks!
I am glad I have been of assistance!