I need to create a table for caching in the postgresql database. Transactions should be as fast as possible, so i thought of creating unlogged table and have a RAM disk as it's tablespace.
There is a warning in the official postgresql documentation:
Placing a tablespace on a temporary file system like a RAM disk risks the reliability of the entire cluster.
I know that unlogged tables are not replicate to the standby and it is okay for me to store unpersistent data in that table. So in case of crash i'm fine with losing it. Here is a questions:
- Is it safe after all to place a tablespace on the RAM disk in this configuration? (unlogged + RAM disk tablespace + unpersistent data)
- If it is a safe option should I create ram disk on a replica too, since creation of tablespace will be stored somewhere in wal?
I'm using EDB 13.9.13 with streaming replication. If this will workout I will do the same for Postgresql v14.7