Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gIM2x-00063K-3M for pgsql-general@arkaria.postgresql.org; Thu, 01 Nov 2018 23:06:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gIM2u-00013R-N5 for pgsql-general@arkaria.postgresql.org; Thu, 01 Nov 2018 23:06:36 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1gIM2u-0000lo-Dl for pgsql-general@lists.postgresql.org; Thu, 01 Nov 2018 23:06:36 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gIM2r-00065n-Oj for pgsql-general@lists.postgresql.org; Thu, 01 Nov 2018 23:06:35 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 714285F79F; Thu, 1 Nov 2018 19:06:32 -0400 (EDT) Date: Thu, 1 Nov 2018 19:06:32 -0400 From: Stephen Frost To: Ravi Krishna Cc: david.g.johnston@gmail.com, pgsql-general@lists.postgresql.org Subject: Re: Truncation of UNLOGGED tables upon restart. Message-ID: <20181101230632.GK4184@tamriel.snowman.net> References: <1951433141.20816140.1541105355093.ref@mail.yahoo.com> <1951433141.20816140.1541105355093@mail.yahoo.com> <1177060548.6477958.1541107219801@mail.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Wys2sP4IVlcg57w5" Content-Disposition: inline In-Reply-To: <1177060548.6477958.1541107219801@mail.yahoo.com> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Wys2sP4IVlcg57w5 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Ravi Krishna (srkrishna1@aol.com) wrote: > > There is no such thing as a "read only" table in PostgreSQL.=A0 All tab= les are read/write no matter that frequency of either event.=A0 There is no= thing > inherently special about "no writes for 4 days" and "no writes for = 10 seconds" that would allow for a distinction to be made.=A0 There could b= e write > in progress on the table just as it crashes Friday. >=20 > I am aware that unlogged tables have no entries in WAL, but I assumed (in= correctly) that PG will at least keep track whether any writes was done on = a table since last checkpoint, and if none, it will find no reason to trunc= ate it. No, we don't currently track that information but it's an interesting idea, at least imv. > The use case I was thinking about is that if we have to load a large set = of data every weekend and use it for reporting until next weekend, why not = create those tables as unlogged. Seems like a pretty useful use-case. I had been thinking for a while, based on a comment made be someone else (Vik Fearing..), that we should have a way to turn an unlogged table into an 'init table' or similar- that is, just copy the data from the main fork into the init fork and then fsync it, then the data is there on restart. Having a way to say 'this data has been fsyncd' is a pretty interesting idea though. I wonder how hard it'd be to make that work. Thanks! Stephen --Wys2sP4IVlcg57w5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJb24b4AAoJEO1sijiDR2RVPpwP/RUhYqS4DcYi40ONmxI4yVxo ZAnSybiEtLD8S9hXVx3N38l9/a4fNGBjiFuKm7jfrs+rj4Rl+iSpBxbb9eZ2jse/ foyKf1mLU+dY5E7VcYECa+W5fXVfGgnzSf8w4WlLWQFGxfIHJaIc2UYSgT2sAMsE yH6SGgq5mXvsYzs2JMTUZGzwLTGQkXo1maiHzsh94WXoq+6GDTX6fX6/aeY8aLSr MILKQjpsW5RGeu2cPDoMT1g40BG3lbOBuhDeS1spuiAWfAq4Im5f2qVyu1MoF8UP ruS/fVJrbOW1xibopVMGJ0lUGpOhn6dCuDzobU/HWKRWBQvofIEfnK3poDYTXznc yrHG5Q0zwPBOo1yfZfHptoxU4TJhUXXMh/UGQAQl3lLAOHqWRViuy2NTo2WlX7oo vWsFIpPT+dXXSIn9NEVa3/x1tDwUbDj5Ioe5/Nb+hMxNAi5FqO1559+VPPTANZbn ELP3zEUixPtHYmvXXB9ey1L5UXgwI/GQWEC2rWjFIPMgXlK5KGs+DUa1wij9+a/A fNJ47sFcCf14h0QfWgzAvTrxy+npK53UJsWJLeoEe7rsIE/l6hb2iB2mulq1eBZj hQjoPs/hMbg6AbYf3WJEy19l4/yGfFj9ea4i3bl67EEt1PMdD1lwx2dw+B5aeC7K EoGYoql9kUwVVUs7HeQj =agRF -----END PGP SIGNATURE----- --Wys2sP4IVlcg57w5--