Wednesday, September 23, 2009

PostgreSQL as in-memory database

I was reading a specifications of few in-memory databases (here and here). So I started to think how can I and can I use PostgreSQL as in-memory DB ...

Yes! This is possible!

There is one feature in PostgreSQL called "table space". You can register a folder from the file system as data storage. This is the basic procedure.

1. In this article Linux Memory/Temporary File System (FS) you can read how to mount a portion of the memory to a folder.
2. Using the "table space" feature of PostgreSQL to link this virtual folder in the server.
3. Create/Delete/Update tables!

This is it, sounds easy right ;)

But what is the practical aplication for this?
This table space can be used for cache or temporary data of any kind. This in my opinion will increase the speed of your applications.

In my next post I'll publish some speed tests.