Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jEHn5-0008AN-Js for pgsql-general@arkaria.postgresql.org; Tue, 17 Mar 2020 19:22:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jEHn3-0005XC-5X for pgsql-general@arkaria.postgresql.org; Tue, 17 Mar 2020 19:22:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jEHn2-0005X5-Rn for pgsql-general@lists.postgresql.org; Tue, 17 Mar 2020 19:22:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jEHmz-0001AQ-CN for pgsql-general@lists.postgresql.org; Tue, 17 Mar 2020 19:22:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 02HJM7Ni018468; Tue, 17 Mar 2020 15:22:07 -0400 From: Tom Lane To: Ron cc: pgsql-general@lists.postgresql.org Subject: Re: Temporary tablespaces on a RAM disk In-reply-to: <427c0a2d-77aa-d931-3738-0128a069c2df@gmail.com> References: <427c0a2d-77aa-d931-3738-0128a069c2df@gmail.com> Comments: In-reply-to Ron message dated "Tue, 17 Mar 2020 12:59:57 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <18466.1584472927.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 17 Mar 2020 15:22:07 -0400 Message-ID: <18467.1584472927@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Ron writes: > On 3/17/20 12:19 PM, David G. Johnston wrote: >> There is a nice big bold warning callout in the documentation that cove= rs = >> this explicitly. >> https://www.postgresql.org/docs/12/manage-ag-tablespaces.html >>> Warning >>> Placing a tablespace on a temporary file system like a RAM disk risks = the = >>> reliability of the entire cluster. > But aren't temporary files removed when you restart Postgres?=C2=A0 (I'm= assuming = > that temp_tablespaces is treated "the same" as data/pgsql_tmp.=C2=A0 Is = that a = > false assumption?) I think the main issue is that there's no mechanism preventing you from putting regular (non-temp) tables into the "temporary" tablespace. If you do, crash recovery will get very unhappy when it tries to replay updates for those tables and they're not there. There are probably additional issues having to do with the tablespace directory(s) disappearing. That, you could maybe finesse by having the postmaster start script re-create any missing directories. All in all, I wouldn't try it without careful pre-testing of what happens after the RAM disk gets wiped. People have asked about this before, so maybe it'd be an idea to make an explicit concept of a temp tablespace that only accepts temp tables, and do whatever is needful to make that robust. But I've not heard of any work towards that. regards, tom lane