- This creates a 560mb ramdisk. Adjust the size accordingly. I think the number at the end of the command is the number of disk blocks. They are 2kb in size for me.
- Restarting postgres is not necessary; you can create the ramdisk and tablespace while postgres is running.
- You will lose all data in the ramdisk tablespace when you shut your machine down
$ diskutil erasevolume HFS+ "postgres_ramdisk" `hdiutil attach -nomount ram://1165430`
Started erase on disk1
Unmounting disk
Erasing
Initialized /dev/rdisk1 as a 569 MB HFS Plus volume
Mounting disk
Finished erase on disk1 postgres_ramdisk
$ sudo chown -R $(whoami) /Volumes/postgres_ramdisk/
$ dropdb westfield_test
$ bundle exec script/dbconsole
psql> create tablespace foo_ramdisk location '/Volumes/postgres_ramdisk';
psql> create database foo_test tablespace = foo_ramdisk;
psql> \q
$ time bundle exec rake spec
Also, update your config/database.yml to include the tablespace declaration:
test:
adapter: postgresql
database: foo_test
tablespace: foo_ramdisk
host: localhost