{"id":13671,"date":"2020-03-18T07:20:21","date_gmt":"2020-03-18T06:20:21","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\/"},"modified":"2020-03-18T07:20:21","modified_gmt":"2020-03-18T06:20:21","slug":"can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\/","title":{"rendered":"Can I put my temporary tablespaces on a RAM disk with PostgreSQL?"},"content":{"rendered":"<p>The short answer to the title of this blog post is: yes, of course you can. The more important question is: should you? The <a href=\"https:\/\/www.postgresql.org\/docs\/current\/manage-ag-tablespaces.html\" target=\"_blank\" rel=\"noopener noreferrer\">PostgreSQL documentation about tablespaces<\/a> contains an explicit warning: &#8220;Placing a tablespace on a temporary file system like a RAM disk risks the reliability of the entire cluster&#8221;. This is for sure true for tablespaces containing persistent data, but what about objects\/files that are created in a temporary tablespace like temporary tables or sorts that are going to disk? Does the warning from the documentation apply to these as well? You can check <a href=\"https:\/\/www.dbi-services.com\/blog\/about-temp_tablespaces-in-postgresql\/\" target=\"_blank\" rel=\"noopener noreferrer\">the last blog about temporary tablespaces<\/a> for getting an idea what actually goes to temporary tablespaces in PostgreSQL. <\/p>\n<p><!--more--><\/p>\n<p>On Linux a RAM disk can be created quite easily:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@centos8pg:\/home\/postgres\/ [pgdev] sudo mkfs  \/dev\/my_ram_disk 81920\nmke2fs 1.44.6 (5-Mar-2019)\nCreating regular file \/dev\/my_ram_disk\nCreating filesystem with 81920 1k blocks and 20480 inodes\nFilesystem UUID: ecc6d90e-2d59-47f8-a598-7726c309c389\nSuperblock backups stored on blocks: \n        8193, 24577, 40961, 57345, 73729\n\nAllocating group tables: done                            \nWriting inode tables: done                            \nWriting superblocks and filesystem accounting information: done \n<\/pre>\n<p>Of course that needs to be mounted somewhere so that we can put a temporary tablespace on it:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@centos8pg:\/home\/postgres\/ [pgdev] sudo mkdir \/my_ram_disk\npostgres@centos8pg:\/home\/postgres\/ [pgdev] sudo mount \/dev\/my_ram_disk \/my_ram_disk\/\npostgres@centos8pg:\/home\/postgres\/ [pgdev] df -h | grep my_ram\n\/dev\/loop0            78M  1.6M   72M   3% \/my_ram_disk\npostgres@centos8pg:\/home\/postgres\/ [pgdev] sudo chown postgres:postgres \/my_ram_disk\n<\/pre>\n<p>I am going to create a new PostgreSQL cluster from scratch:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@centos8pg:\/home\/postgres\/ [pgdev] initdb -D \/var\/tmp\/pg\npostgres@centos8pg:\/home\/postgres\/ [pgdev] export PGPORT=8888\npostgres@centos8pg:\/home\/postgres\/ [pgdev] pg_ctl -D \/var\/tmp\/pg\/ start -l \/dev\/null\n<\/pre>\n<p>Preparing the temporary tablespace and setting it as the default:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">\npostgres@centos8pg:\/home\/postgres\/ [pgdev] psql -X -p 8888 postgres\npsql (13devel)\nType \"help\" for help.\n\npostgres=# ! mkdir \/my_ram_disk\/tbs\/\npostgres=# create tablespace my_temp_tbs location '\/my_ram_disk\/tbs\/';\nCREATE TABLESPACE\npostgres=# db+\n                                       List of tablespaces\n    Name     |  Owner   |     Location     | Access privileges | Options |  Size   | Description \n-------------+----------+------------------+-------------------+---------+---------+-------------\n my_temp_tbs | postgres | \/my_ram_disk\/tbs |                   |         | 0 bytes | \n pg_default  | postgres |                  |                   |         | 22 MB   | \n pg_global   | postgres |                  |                   |         | 559 kB  | \n(3 rows)\n\npostgres=# alter system set temp_tablespaces = 'my_temp_tbs';\nALTER SYSTEM\npostgres=# select pg_reload_conf();\n pg_reload_conf \n----------------\n t\n(1 row)\n\npostgres=# show temp_tablespaces ;\n temp_tablespaces \n------------------\n my_temp_tbs\n(1 row)\n<\/pre>\n<p>Creating a new temporary table should now create the underlying file on the RAM disk:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">\npostgres=# create temporary table tmp1 ( a int, b date );\nCREATE TABLE\npostgres=# select pg_relation_filepath('tmp1');\n              pg_relation_filepath              \n------------------------------------------------\n pg_tblspc\/16384\/PG_13_202003051\/12732\/t3_16387\n(1 row)\npostgres-# ! ls -la \/var\/tmp\/pg\/pg_tblspc\/\ntotal 4\ndrwx------.  2 postgres postgres   19 Mar 16 21:32 .\ndrwx------. 19 postgres postgres 4096 Mar 16 21:32 ..\nlrwxrwxrwx.  1 postgres postgres   16 Mar 16 21:32 16384 -&gt; \/my_ram_disk\/tbs\n<\/pre>\n<p>Everything as expected. What could possibly go wrong with that? Will PostgreSQL start just fine if we put data in that table and then crash the postmaster?<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">\npostgres=# insert into tmp1 select * from generate_series(1,10000);\nINSERT 0 10000\npostgres=# ! ps -ef | grep postgres | grep \"var\/tmp\"\npostgres 25900     1  0 21:31 ?        00:00:00 \/u01\/app\/postgres\/product\/DEV\/db_1\/bin\/postgres -D \/var\/tmp\/pg\npostgres 25992 25911  0 21:47 pts\/0    00:00:00 sh -c ps -ef | grep postgres | grep \"var\/tmp\"\npostgres 25995 25992  0 21:47 pts\/0    00:00:00 grep var\/tmp\npostgres=# ! kill -9 25900\npostgres=# select 1;\nFATAL:  terminating connection due to unexpected postmaster exit\nserver closed the connection unexpectedly\n        This probably means the server terminated abnormally\n        before or while processing the request.\nThe connection to the server was lost. Attempting reset: Failed.\n!?&gt; select 1;\nYou are currently not connected to a database.\n!?&gt; \n<\/pre>\n<p>Can we start normally from here on?<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@centos8pg:\/home\/postgres\/ [pgdev] pg_ctl -D \/var\/tmp\/pg\/ start\npg_ctl: another server might be running; trying to start server anyway\nwaiting for server to start....2020-03-16 21:49:33.034 CET [26010] LOG:  starting PostgreSQL 13devel on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.3.1 20190507 (Red Hat 8.3.1-4), 64-bit\n2020-03-16 21:49:33.035 CET [26010] LOG:  listening on IPv6 address \"::1\", port 8888\n2020-03-16 21:49:33.035 CET [26010] LOG:  listening on IPv4 address \"127.0.0.1\", port 8888\n2020-03-16 21:49:33.037 CET [26010] LOG:  listening on Unix socket \"\/tmp\/.s.PGSQL.8888\"\n2020-03-16 21:49:33.041 CET [26011] LOG:  database system was interrupted; last known up at 2020-03-16 21:36:18 CET\n2020-03-16 21:49:33.263 CET [26011] LOG:  database system was not properly shut down; automatic recovery in progress\n2020-03-16 21:49:33.264 CET [26011] LOG:  redo starts at 0\/156D588\n2020-03-16 21:49:33.264 CET [26011] LOG:  invalid record length at 0\/1574240: wanted 24, got 0\n2020-03-16 21:49:33.264 CET [26011] LOG:  redo done at 0\/1574068\n2020-03-16 21:49:33.277 CET [26010] LOG:  database system is ready to accept connections\n done\nserver started\n<\/pre>\n<p>All is fine. Of course the temporary table is gone but that would also have been the case if we just ended our session instead of killing the postmaster:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">\npostgres@centos8pg:\/home\/postgres\/ [pgdev] psql -X -p 8888 postgres\npsql (13devel)\nType \"help\" for help.\n\npostgres=# d tmp1\nDid not find any relation named \"tmp1\".\npostgres=# db+\n                                        List of tablespaces\n    Name     |  Owner   |     Location     | Access privileges | Options |    Size    | Description \n-------------+----------+------------------+-------------------+---------+------------+-------------\n my_temp_tbs | postgres | \/my_ram_disk\/tbs |                   |         | 1024 bytes | \n pg_default  | postgres |                  |                   |         | 22 MB      | \n pg_global   | postgres |                  |                   |         | 559 kB     | \n(3 rows)\n\npostgres=# \n<\/pre>\n<p>Sort operations will just work fine on that tablespace as well:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">\npostgres=# select * from generate_series(1,1000000) order by random();\n generate_series \n-----------------\n          943370\n          301661\n...\n<\/pre>\n<p>&#8230; but you need to be careful with the size of the RAM disk:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">\npostgres=# select * from generate_series(1,5000000) order by random();\n2020-03-16 22:04:47.738 CET [26026] ERROR:  could not write block 629 of temporary file: No space left on device\n2020-03-16 22:04:47.738 CET [26026] STATEMENT:  select * from generate_series(1,5000000) order by random();\nERROR:  could not write block 629 of temporary file: No space left on device\n<\/pre>\n<p>So actually you can put a temporary tablespace on a RAM disk and I am not aware of serious issues, even if you lose the RAM disk that can easily be fixed:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">\npostgres@centos8pg:\/home\/postgres\/ [pgdev] sudo umount \/my_ram_disk \npostgres@centos8pg:\/home\/postgres\/ [pgdev] pg_ctl -D \/var\/tmp\/pg\/ restart\nwaiting for server to shut down....2020-03-16 22:06:23.118 CET [26010] LOG:  received fast shutdown request\n2020-03-16 22:06:23.124 CET [26010] LOG:  aborting any active transactions\n2020-03-16 22:06:23.133 CET [26010] LOG:  background worker \"logical replication launcher\" (PID 26017) exited with exit code 1\n2020-03-16 22:06:23.133 CET [26012] LOG:  shutting down\n2020-03-16 22:06:23.148 CET [26010] LOG:  database system is shut down\n done\nserver stopped\nwaiting for server to start....2020-03-16 22:06:23.281 CET [26236] LOG:  starting PostgreSQL 13devel on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.3.1 20190507 (Red Hat 8.3.1-4), 64-bit\n2020-03-16 22:06:23.282 CET [26236] LOG:  listening on IPv6 address \"::1\", port 8888\n2020-03-16 22:06:23.282 CET [26236] LOG:  listening on IPv4 address \"127.0.0.1\", port 8888\n2020-03-16 22:06:23.286 CET [26236] LOG:  listening on Unix socket \"\/tmp\/.s.PGSQL.8888\"\n2020-03-16 22:06:23.289 CET [26236] LOG:  could not open directory \"pg_tblspc\/16384\/PG_13_202003051\": No such file or directory\n2020-03-16 22:06:23.293 CET [26237] LOG:  database system was shut down at 2020-03-16 22:06:23 CET\n2020-03-16 22:06:23.293 CET [26237] LOG:  could not open directory \"pg_tblspc\/16384\/PG_13_202003051\": No such file or directory\n2020-03-16 22:06:23.299 CET [26236] LOG:  database system is ready to accept connections\n done\nserver started\n<\/pre>\n<p>PostreSQL will complain but it will start and once the RAM disk is avaialble again there is business as usual:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">\npostgres@centos8pg:\/home\/postgres\/ [pgdev] sudo mount \/dev\/my_ram_disk \/my_ram_disk\/\n22:07:33 postgres@centos8pg:\/home\/postgres\/ [pgdev] psql -X -p 8888 postgres\npsql (13devel)\nType \"help\" for help.\n\npostgres=# create temporary table tmp1 ( a int );\nCREATE TABLE\npostgres=# ! ls -la \/my_ram_disk\/\ntotal 19\ndrwxr-xr-x.  4 postgres postgres  1024 Mar 16 21:31 .\ndr-xr-xr-x. 23 root     root      4096 Mar 16 21:28 ..\ndrwx------.  2 root     root     12288 Mar 16 21:27 lost+found\ndrwx------.  3 postgres postgres  1024 Mar 16 21:32 tbs\npostgres=# ! ls -la \/my_ram_disk\/tbs\/\ntotal 5\ndrwx------. 3 postgres postgres 1024 Mar 16 21:32 .\ndrwxr-xr-x. 4 postgres postgres 1024 Mar 16 21:31 ..\ndrwx------. 4 postgres postgres 1024 Mar 16 22:02 PG_13_202003051\npostgres=# \n<\/pre>\n<p>If you know any issues with that or have any comments I would be happy if you can share your thoughts. <\/p>\n<p>Another option would by to use <a href=\"https:\/\/en.wikipedia.org\/wiki\/Tmpfs\" target=\"_blank\" rel=\"noopener noreferrer\">tmpfs<\/a>:<\/p>\n<pre class=\"brush: bash; gutter: true; first-line: 1\">\npostgres@centos8pg:\/home\/postgres\/ [pgdev] sudo mkdir \/my_ram_disk_2\/\npostgres@centos8pg:\/home\/postgres\/ [pgdev] sudo mount -t tmpfs -o size=2G tmpfs \/my_ram_disk_2\/\npostgres@centos8pg:\/home\/postgres\/ [pgdev] df -h | grep disk_2\ntmpfs                2.0G     0  2.0G   0% \/my_ram_disk_2\n<\/pre>\n<p>This can be used for temporary tablespaces as well:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">\npostgres@centos8pg:\/home\/postgres\/ [pgdev] psql -X -p 8888 postgres\npsql (13devel)\nType \"help\" for help.\n\npostgres=# ! sudo chown postgres:postgres \/my_ram_disk_2\/\npostgres=# ! mkdir \/my_ram_disk_2\/tbs2\npostgres=# create tablespace my_temp_tbs2 location '\/my_ram_disk_2\/tbs2';\nCREATE TABLESPACE\npostgres=# db+\n                                          List of tablespaces\n     Name     |  Owner   |      Location       | Access privileges | Options |    Size    | Description \n--------------+----------+---------------------+-------------------+---------+------------+-------------\n my_temp_tbs  | postgres | \/my_ram_disk\/tbs    |                   |         | 2048 bytes | \n my_temp_tbs2 | postgres | \/my_ram_disk_2\/tbs2 |                   |         | 0 bytes    | \n pg_default   | postgres |                     |                   |         | 22 MB      | \n pg_global    | postgres |                     |                   |         | 559 kB     | \n(4 rows)\n\npostgres=# alter system set temp_tablespaces = 'my_temp_tbs2';\nALTER SYSTEM\npostgres=# select pg_reload_conf();\n pg_reload_conf \n----------------\n t\n(1 row)\n\npostgres=# show temp_tablespaces ;\n temp_tablespaces \n------------------\n my_temp_tbs2\n(1 row)\n<\/pre>\n<p>Same test as above:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">\npostgres=# create temporary table tmp3 ( a int );\nCREATE TABLE\npostgres=# insert into tmp3 select * from generate_series(1,10000);\nINSERT 0 10000\npostgres=# select pg_relation_filepath('tmp3');\n              pg_relation_filepath              \n------------------------------------------------\n pg_tblspc\/24583\/PG_13_202003051\/12732\/t3_24587\n(1 row)\n\npostgres=# ! ls -la \/var\/tmp\/pg\/pg_tblspc\/\ntotal 4\ndrwx------.  2 postgres postgres   32 Mar 16 22:31 .\ndrwx------. 19 postgres postgres 4096 Mar 16 22:32 ..\nlrwxrwxrwx.  1 postgres postgres   16 Mar 16 21:32 16384 -&gt; \/my_ram_disk\/tbs\nlrwxrwxrwx.  1 postgres postgres   19 Mar 16 22:31 24583 -&gt; \/my_ram_disk_2\/tbs2\npostgres=# ! ps -ef | grep postgres | grep \"var\/tmp\"\npostgres 26236     1  0 22:06 ?        00:00:00 \/u01\/app\/postgres\/product\/DEV\/db_1\/bin\/postgres -D \/var\/tmp\/pg\npostgres 26412 26379  0 22:35 pts\/0    00:00:00 sh -c ps -ef | grep postgres | grep \"var\/tmp\"\npostgres 26415 26412  0 22:35 pts\/0    00:00:00 grep var\/tmp\npostgres=# ! kill -9 26236\npostgres=# select 1;\nFATAL:  terminating connection due to unexpected postmaster exit\nserver closed the connection unexpectedly\n        This probably means the server terminated abnormally\n        before or while processing the request.\nThe connection to the server was lost. Attempting reset: Failed.\n!?&gt; select 1;\nYou are currently not connected to a database.\n!?&gt; \n<\/pre>\n<p>PostgreSQL will start just fine:<\/p>\n<pre class=\"brush: sql; gutter: true; first-line: 1\">\npostgres@centos8pg:\/home\/postgres\/ [pgdev] pg_ctl -D \/var\/tmp\/pg\/ start\npg_ctl: another server might be running; trying to start server anyway\nwaiting for server to start....2020-03-16 22:37:44.903 CET [26431] LOG:  starting PostgreSQL 13devel on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.3.1 20190507 (Red Hat 8.3.1-4), 64-bit\n2020-03-16 22:37:44.903 CET [26431] LOG:  listening on IPv6 address \"::1\", port 8888\n2020-03-16 22:37:44.903 CET [26431] LOG:  listening on IPv4 address \"127.0.0.1\", port 8888\n2020-03-16 22:37:44.906 CET [26431] LOG:  listening on Unix socket \"\/tmp\/.s.PGSQL.8888\"\n2020-03-16 22:37:44.910 CET [26432] LOG:  database system was interrupted; last known up at 2020-03-16 22:31:24 CET\n2020-03-16 22:37:45.172 CET [26432] LOG:  database system was not properly shut down; automatic recovery in progress\n2020-03-16 22:37:45.173 CET [26432] LOG:  redo starts at 0\/15A1EC8\n2020-03-16 22:37:45.174 CET [26432] LOG:  invalid record length at 0\/15B9E88: wanted 24, got 0\n2020-03-16 22:37:45.174 CET [26432] LOG:  redo done at 0\/15B9CD0\n2020-03-16 22:37:45.195 CET [26431] LOG:  database system is ready to accept connections\n done\nserver started\n<\/pre>\n<p>To conclude: I am not sure if I would do this in real life but it seems to work quite well. As long as no persistent objects go into these tablespaces all should be fine. I&#8217;ve asked the mailing list for any experience with this, you can <a href=\"https:\/\/www.postgresql.org\/message-id\/flat\/ZR0P278MB0028A89FAA3E31E7F1514EF6D2F60%40ZR0P278MB0028.CHEP278.PROD.OUTLOOK.COM\" target=\"_blank\" rel=\"noopener noreferrer\">follow that here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The short answer to the title of this blog post is: yes, of course you can. The more important question is: should you? The PostgreSQL documentation about tablespaces contains an explicit warning: &#8220;Placing a tablespace on a temporary file system like a RAM disk risks the reliability of the entire cluster&#8221;. This is for sure [&hellip;]<\/p>\n","protected":false},"author":29,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[229],"tags":[77],"type_dbi":[],"class_list":["post-13671","post","type-post","status-publish","format-standard","hentry","category-database-administration-monitoring","tag-postgresql"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Can I put my temporary tablespaces on a RAM disk with PostgreSQL? - dbi Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Can I put my temporary tablespaces on a RAM disk with PostgreSQL?\" \/>\n<meta property=\"og:description\" content=\"The short answer to the title of this blog post is: yes, of course you can. The more important question is: should you? The PostgreSQL documentation about tablespaces contains an explicit warning: &#8220;Placing a tablespace on a temporary file system like a RAM disk risks the reliability of the entire cluster&#8221;. This is for sure [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2020-03-18T06:20:21+00:00\" \/>\n<meta name=\"author\" content=\"Daniel Westermann\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@westermanndanie\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Daniel Westermann\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\\\/\"},\"author\":{\"name\":\"Daniel Westermann\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/8d08e9bd996a89bd75c0286cbabf3c66\"},\"headline\":\"Can I put my temporary tablespaces on a RAM disk with PostgreSQL?\",\"datePublished\":\"2020-03-18T06:20:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\\\/\"},\"wordCount\":427,\"commentCount\":0,\"keywords\":[\"PostgreSQL\"],\"articleSection\":[\"Database Administration &amp; Monitoring\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\\\/\",\"name\":\"Can I put my temporary tablespaces on a RAM disk with PostgreSQL? - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"datePublished\":\"2020-03-18T06:20:21+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/8d08e9bd996a89bd75c0286cbabf3c66\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Can I put my temporary tablespaces on a RAM disk with PostgreSQL?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/8d08e9bd996a89bd75c0286cbabf3c66\",\"name\":\"Daniel Westermann\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g\",\"caption\":\"Daniel Westermann\"},\"description\":\"Daniel Westermann is Principal Consultant and Technology Leader Open Infrastructure at dbi services. He has more than 15 years of experience in management, engineering and optimization of databases and infrastructures, especially on Oracle and PostgreSQL. Since the beginning of his career, he has specialized in Oracle Technologies and is Oracle Certified Professional 12c and Oracle Certified Expert RAC\\\/GridInfra. Over time, Daniel has become increasingly interested in open source technologies, becoming \u201cTechnology Leader Open Infrastructure\u201d and PostgreSQL expert. \u00a0Based on community or EnterpriseDB tools, he develops and installs complex high available solutions with PostgreSQL. He is also a certified PostgreSQL Plus 9.0 Professional and a Postgres Advanced Server 9.4 Professional. He is a regular speaker at PostgreSQL conferences in Switzerland and Europe. Today Daniel is also supporting our customers on AWS services such as AWS RDS, database migrations into the cloud, EC2 and automated infrastructure management with AWS SSM (System Manager). He is a certified AWS Solutions Architect Professional. Prior to dbi services, Daniel was Management System Engineer at LC SYSTEMS-Engineering AG in Basel. Before that, he worked as Oracle Developper &amp;\u00a0Project Manager at Delta Energy Solutions AG in Basel (today Powel AG). Daniel holds a diploma in Business Informatics (DHBW, Germany). His branch-related experience mainly covers the pharma industry, the financial sector, energy, lottery and telecommunications.\",\"sameAs\":[\"https:\\\/\\\/x.com\\\/westermanndanie\"],\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/daniel-westermann\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Can I put my temporary tablespaces on a RAM disk with PostgreSQL? - dbi Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\/","og_locale":"en_US","og_type":"article","og_title":"Can I put my temporary tablespaces on a RAM disk with PostgreSQL?","og_description":"The short answer to the title of this blog post is: yes, of course you can. The more important question is: should you? The PostgreSQL documentation about tablespaces contains an explicit warning: &#8220;Placing a tablespace on a temporary file system like a RAM disk risks the reliability of the entire cluster&#8221;. This is for sure [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\/","og_site_name":"dbi Blog","article_published_time":"2020-03-18T06:20:21+00:00","author":"Daniel Westermann","twitter_card":"summary_large_image","twitter_creator":"@westermanndanie","twitter_misc":{"Written by":"Daniel Westermann","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\/"},"author":{"name":"Daniel Westermann","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d08e9bd996a89bd75c0286cbabf3c66"},"headline":"Can I put my temporary tablespaces on a RAM disk with PostgreSQL?","datePublished":"2020-03-18T06:20:21+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\/"},"wordCount":427,"commentCount":0,"keywords":["PostgreSQL"],"articleSection":["Database Administration &amp; Monitoring"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\/","url":"https:\/\/www.dbi-services.com\/blog\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\/","name":"Can I put my temporary tablespaces on a RAM disk with PostgreSQL? - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2020-03-18T06:20:21+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d08e9bd996a89bd75c0286cbabf3c66"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/can-i-put-my-temporary-tablespaces-on-a-ram-disk-with-postgresql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Can I put my temporary tablespaces on a RAM disk with PostgreSQL?"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d08e9bd996a89bd75c0286cbabf3c66","name":"Daniel Westermann","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/31350ceeecb1dd8986339a29bf040d4cd3cd087d410deccd8f55234466d6c317?s=96&d=mm&r=g","caption":"Daniel Westermann"},"description":"Daniel Westermann is Principal Consultant and Technology Leader Open Infrastructure at dbi services. He has more than 15 years of experience in management, engineering and optimization of databases and infrastructures, especially on Oracle and PostgreSQL. Since the beginning of his career, he has specialized in Oracle Technologies and is Oracle Certified Professional 12c and Oracle Certified Expert RAC\/GridInfra. Over time, Daniel has become increasingly interested in open source technologies, becoming \u201cTechnology Leader Open Infrastructure\u201d and PostgreSQL expert. \u00a0Based on community or EnterpriseDB tools, he develops and installs complex high available solutions with PostgreSQL. He is also a certified PostgreSQL Plus 9.0 Professional and a Postgres Advanced Server 9.4 Professional. He is a regular speaker at PostgreSQL conferences in Switzerland and Europe. Today Daniel is also supporting our customers on AWS services such as AWS RDS, database migrations into the cloud, EC2 and automated infrastructure management with AWS SSM (System Manager). He is a certified AWS Solutions Architect Professional. Prior to dbi services, Daniel was Management System Engineer at LC SYSTEMS-Engineering AG in Basel. Before that, he worked as Oracle Developper &amp;\u00a0Project Manager at Delta Energy Solutions AG in Basel (today Powel AG). Daniel holds a diploma in Business Informatics (DHBW, Germany). His branch-related experience mainly covers the pharma industry, the financial sector, energy, lottery and telecommunications.","sameAs":["https:\/\/x.com\/westermanndanie"],"url":"https:\/\/www.dbi-services.com\/blog\/author\/daniel-westermann\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/13671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/29"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=13671"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/13671\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=13671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=13671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=13671"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=13671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}