Re: Why does PostgreSQL ftruncate before unlink?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jon Nelson <jnelson+pgsql(at)jamponi(dot)net>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>, pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Why does PostgreSQL ftruncate before unlink?
Date: 2014-02-24 04:07:36
Message-ID: 5141.1393214856@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jon Nelson <jnelson+pgsql(at)jamponi(dot)net> writes:
> On Sun, Feb 23, 2014 at 9:49 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> If memory serves, the inode should get removed during the next checkpoint.

> I was moments away from commenting to say that I had traced the flow
> of the code to md.c and found the comments there quite illuminating. I
> wonder if there is a different way to solve the underlying issue
> without relying on ftruncate (which seems to be somewhat expensive).

Hm. The code is designed the way it is on the assumption that ftruncate
doesn't do anything that unlink wouldn't have to do anyway. If it really
is significantly slower on popular filesystems, maybe we need to revisit
that.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Felix.徐 2014-02-24 06:45:30 How to convert a double value to a numeric datum type in pgsql?
Previous Message Jon Nelson 2014-02-24 04:00:09 Re: Why does PostgreSQL ftruncate before unlink?