Do you need to drop Pg for this?
If you're unit testing against a different database than you run against in production your tests just won't be as good.
Try this: Optimise PostgreSQL for fast testing .
... and see how you go.
update: You might think putting everything on a ramdisk will make your tests massively faster, but you're probably mistaken. It's often more efficient to let data that isn't in use spill to disk so the system can use more RAM for the task at hand. Using unlogged
tables and proper async commit or (for testing only, will eat your data) fsync=off
should get you very similar speeds.
If you really require a true in-memory tables, create a file system on a ramdisk or tmpfs and initdb a new cluster in there. You might as well use UNLOGGED
tables so they don't go through the write-ahead log.
Note that while tmpfs
is a ramdisk, it allows less-used pages to go to swapspace. If you absolutely must have all the data pinned in RAM for some reason, you'll need to use the ramdisk
driver and create a file system on a ramdisk instead. My advice: don't do it. Just configure Pg properly for fast testing.