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 1gIKXV-0001wI-H7 for pgsql-general@arkaria.postgresql.org; Thu, 01 Nov 2018 21:30:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gIKXT-0001pG-Jz for pgsql-general@arkaria.postgresql.org; Thu, 01 Nov 2018 21:30:03 +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 1gIKXT-0001p8-CG for pgsql-general@lists.postgresql.org; Thu, 01 Nov 2018 21:30:03 +0000 Received: from mail-oi1-x22c.google.com ([2607:f8b0:4864:20::22c]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gIKXR-0003jX-4v for pgsql-general@lists.postgresql.org; Thu, 01 Nov 2018 21:30:02 +0000 Received: by mail-oi1-x22c.google.com with SMTP id e3-v6so17890367oiy.6 for ; Thu, 01 Nov 2018 14:30:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=XaYB1RjCl00S0EiSGVH8bgdIIxMz+jK0uQZATkV8PRI=; b=douolKjRXFJkCgsK5ldEn6yNjymCzQ9JA9ngCxHKcmPYT9YK8ClYw7/EjdQX15Qkj1 JIFHhcrmcy/xpJdBdU+JpHqLFZONKr8E93/d26J3Rt/cSyOmRQX9ChDErVTy6uBzzkEW JtSCKETW20KbsOY4MvohY4P/BrI4nT7VN7jwbBcg1H7VFWUf3XSWEPcDDxI+GASSQWfH mr6urr3oJF4mnD/Q0hyqedxU4PjqsGWVFmmGonnCdPruDBS0CDwugXlQZkKPb3cYqDKG zFHDm6yGK3BJQB0vW1UNhUAuN9cTZQylnRC/sY58Z//GM8JBcpJufd6g+jNbZbKxtpjD I31A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=XaYB1RjCl00S0EiSGVH8bgdIIxMz+jK0uQZATkV8PRI=; b=Gg+MVTazwcTgmcPWXCBGeMgZTQWHuVLxwzr3Velnp4ut2UdY7UGqAveTTxUafQWfWb 1BBEkKwgLgkIdq+rRXCUvbQ7lyOGH+miuEgrA9HrRKr/Cw5n9sbAZ0ySXWSpxPvA6w7b 5w6tXx0uE+jRhKkqfx32gAGy9cF56RVvbVPBHgZxwH/jQPPzX4+Ndh1XD4aXuL7IMrH/ v1GqiTHdexaOG5JNgyEkCxb//YVhUjRPba1/Ropi+b8aUC6i3oCN84RSauT+FIHca4Tw WW7JuPGmn6SasSKcIYnoogaJxBu9v/1cL5VzgTjVe+5P0jsZFk4Sjs1cydUPNLqO1q2Q soPA== X-Gm-Message-State: AGRZ1gJwp9UEIz2Mw0x41V9pQTli4eSs+PEwAPRg3vz23wUT6mAXpwZz Pou07fb/GkeWIt72hu1IGJnYtPgh X-Google-Smtp-Source: AJdET5ck4kABNHAEhFAqny58OQwlUo/nWqWDLbVQLcYwaGg/z0jnNYtjLy4ZLMyLUcV/D5qpAQgOdg== X-Received: by 2002:aca:59c4:: with SMTP id n187-v6mr5001238oib.279.1541107798897; Thu, 01 Nov 2018 14:29:58 -0700 (PDT) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id g17sm6603036otl.22.2018.11.01.14.29.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Nov 2018 14:29:57 -0700 (PDT) Subject: Re: Truncation of UNLOGGED tables upon restart. To: pgsql-general@lists.postgresql.org References: <1951433141.20816140.1541105355093.ref@mail.yahoo.com> <1951433141.20816140.1541105355093@mail.yahoo.com> From: Ron Message-ID: Date: Thu, 1 Nov 2018 16:29:57 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------4FFD49AE1229EC4C4B0C2580" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------4FFD49AE1229EC4C4B0C2580 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 11/01/2018 03:58 PM, David G. Johnston wrote: > On Thu, Nov 1, 2018 at 1:49 PM Ravi Krishna > wrote: > > Per documentation unlogged tables are not crash safe and PG will > truncate it when it restarts after a crash. Does this apply to even > read only unlogged tables. > > For example: > > On Monday I load data into unlogged tables. > > Then from Tue onwards the table is only read by application. > > On Fri morning PG crashes.  When it restarts will it truncate all > unlogged tables even though they remained > unchanged.  I hope it does not. > > > "an unlogged table is automatically truncated after a crash or unclean > shutdown." - there are no exceptions noted. > > There is no such thing as a "read only" table in PostgreSQL.  All tables > are read/write no matter that frequency of either event.  There is nothing > inherently special about "no writes for 4 days" and "no writes for 10 > seconds" that would allow for a distinction to be made.  There could be > write in progress on the table just as it crashes Friday. Too bad you can't say ALTER TABLESPACE foo SET READONLY = false; That would effectively give you read only tables.  I've done that before on the legacy RDBMS I managed. -- Angular momentum makes the world go 'round. --------------4FFD49AE1229EC4C4B0C2580 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit On 11/01/2018 03:58 PM, David G. Johnston wrote:
On Thu, Nov 1, 2018 at 1:49 PM Ravi Krishna <srkrishna1@aol.com> wrote:
Per documentation unlogged tables are not crash safe and PG will truncate it when it restarts after a crash. Does this apply to even read only unlogged tables.

For example:

On Monday I load data into unlogged tables.

Then from Tue onwards the table is only read by application.

On Fri morning PG crashes.  When it restarts will it truncate all unlogged tables even though they remained
unchanged.  I hope it does not.

"an unlogged table is automatically truncated after a crash or unclean shutdown." - there are no exceptions noted.

There is no such thing as a "read only" table in PostgreSQL.  All tables are read/write no matter that frequency of either event.  There is nothing inherently special about "no writes for 4 days" and "no writes for 10 seconds" that would allow for a distinction to be made.  There could be write in progress on the table just as it crashes Friday.

Too bad you can't say ALTER TABLESPACE foo SET READONLY = false;

That would effectively give you read only tables.  I've done that before on the legacy RDBMS I managed.

--
Angular momentum makes the world go 'round.
--------------4FFD49AE1229EC4C4B0C2580--