YJ Park's profileYJParkPhotosBlogListsMore Tools Help

Blog


    8/8/2006

    Runing Postgresql in Ramfs for Great Performance in Testing

    As a database server, postgresql make a lot efforts to make the data as secure as possible, but in some certain cases, we don't need these features, we just want it as fast as possible, e.g. in testing. When doing testing, postgresql will access disk to write the data and logs, cause a very big iowait. By running postgresql in ramfs, we can make it much faster.
     
    Ramfs is just using ram to simulate a file system, it's in ram, so it's very fast, of course you need to have enough ram for that.
     
    Here is the script I use to start a second postgresql server at a given port:
    sudo umount /var/test_db_ram
    sudo mount -t ramfs -o size=128M ramfs /var/test_db_ram
    sudo chown postgres:postgres /var/test_db_ram
    sudo chmod 600 /var/test_db_ram
    sudo -u postgres /usr/lib/postgresql/8.1/bin/initdb /var/test_db_ram --locale=en_US.UTF8 --encoding=UTF8
    sudo -u postgres cp /etc/postgresql/8.1/main/* /var/test_db_ram/
    sudo -u postgres /usr/lib/postgresql/8.1/bin/postmaster -D /var/test_db_ram -p 15432 -h "*"
     
    After the server start, need to do some setup:

    sudo -u postgres createuser -p 15432 yjpark -s -d
    Using it in nordicbet team:
    the postgresql port support is in trunk now, you can just add these two lines to your local config:
    db_port = 15432
    db_ip_port = 15432
     
    After setting this, I can run the ftest 30% to 40% faster, I think it's pretty worth doing.