Skip to content

Instantly share code, notes, and snippets.

@brianglass
Created June 6, 2012 20:42
Show Gist options
  • Save brianglass/2884627 to your computer and use it in GitHub Desktop.
Save brianglass/2884627 to your computer and use it in GitHub Desktop.
postgres ramdisk
Create ramdisk:
sudo mkdir <foo>
Add to /etc/fstab:
tmpfs <foo> tmpfs size=4G,mode=1700,uid=114,gid=125 0 1
Mount the ramdisk:
sudo mount <foo>
From psql:
create tablespace ramdisk location '/var/lib/postgres_ramdisk';
I actually have a script I run to fix this since it gets corrupted after a reboot. It's just:
echo "drop tablespace ramdisk; create tablespace ramdisk location '/var/lib/postgres_ramdisk';" | psql
Add to settings.py:
TEST_INIT_SQL = 'set default_tablespace = ramdisk; set synchronous_commit = off'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment