PostgreSQL equivalent of MySQL memory tables?

Elliot B. picture Elliot B. · Jul 30, 2012 · Viewed 29.7k times · Source

Does PostgreSQL have an equivalent of MySQL memory tables?

These MySQL memory tables can persist across sessions (i.e., different from temporary tables which drop at the end of the session). I haven't been able to find anything with PostgreSQL that can do the same.

Answer

aleroot picture aleroot · Jul 30, 2012

No, at the moment they don't exist in PostgreSQL. If you truly need a memory table you can create a RAM disk, add a tablespace for it, and create tables on it.

If you only need the temporary table that is visible between different sessions, you can use an UNLOGGED table. These are not true memory tables but they'll behave surprisingly similarly when the table data is significantly smaller than the system RAM.

Global temporary tables would be another option but are not supported in PostgreSQL as of 9.2 (see comments).