Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aG7kQ-0006uc-3o for pgsql-performance@arkaria.postgresql.org; Mon, 04 Jan 2016 16:12:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aG7kP-0007En-IP for pgsql-performance@arkaria.postgresql.org; Mon, 04 Jan 2016 16:12:41 +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.84) (envelope-from ) id 1aG7kP-0007Eh-7W for pgsql-performance@postgresql.org; Mon, 04 Jan 2016 16:12:41 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aG7kM-0001aF-G8 for pgsql-performance@postgresql.org; Mon, 04 Jan 2016 16:12:40 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id 7F122860002; Mon, 4 Jan 2016 17:12:37 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-5.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from anarazel.de (p54BEB791.dip0.t-ipconnect.de [84.190.183.145]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id A3122860001; Mon, 4 Jan 2016 17:12:34 +0100 (CET) Received: by anarazel.de (Postfix, from userid 1000) id 25B9710BD13; Mon, 4 Jan 2016 17:12:34 +0100 (CET) Date: Mon, 4 Jan 2016 17:12:34 +0100 From: Andres Freund To: Mark Zealey Cc: pgsql-performance@postgresql.org Subject: Re: Proposal for unlogged tables Message-ID: <20160104161234.GE28025@awork2.anarazel.de> References: <568A429C.2010507@allaroundtheworld.fr> <568A8168.1070900@zioup.com> <568A83F0.7050904@allaroundtheworld.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <568A83F0.7050904@allaroundtheworld.fr> X-Pg-Spam-Score: -4.2 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 2016-01-04 16:38:40 +0200, Mark Zealey wrote: > I don't know how the internals work but unlogged tables definitely flushed > to disk and persist through normal server restarts. It is just according to > the docs if the server ever has an unclean shutdown the tables are truncated > even if they have not been updated in a year. I can't understand why it has > to be like this and it seems that it would be much nicer to not > automatically truncate if it doesn't have to. Pages containing data of unlogged tables aren't ever flushed to disk unless a) a shutdown checkpoint is performed b) a buffer containing data from an unlogged table is used for something else c) the database being copied is the the source of a CREATE DATABASE .. TEMPLATE Hence, if there's an unclean shutdown, there's absolutely no guarantee about the on-disk state of unlogged tables. Even if they haven't been modified in ages - there could have been many many dirty pages in shared buffers when crashing. Always flushing dirty pages of unlogged tables at checkpoint would greatly increase the overhead for memory resident, write heavy workloads that use unlogged tables. Andres -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance