Re: drop/truncate table sucks for large values of shared buffers

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: drop/truncate table sucks for large values of shared buffers
Date: 2015-06-28 15:56:47
Message-ID: CANP8+jKUu6WBNGJvG3aoHDVXN8A0evY-_zoCRMq_G+md3nMkwg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 27 June 2015 at 15:10, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> writes:
> > I have looked into it and found that the main reason for such
> > a behaviour is that for those operations it traverses whole
> > shared_buffers and it seems to me that we don't need that
> > especially for not-so-big tables. We can optimize that path
> > by looking into buff mapping table for the pages that exist in
> > shared_buffers for the case when table size is less than some
> > threshold (say 25%) of shared buffers.
>
> I don't like this too much because it will fail badly if the caller
> is wrong about the maximum possible page number for the table, which
> seems not exactly far-fetched. (For instance, remember those kernel bugs
> we've seen that cause lseek to lie about the EOF position?) It also
> offers no hope of a fix for the other operations that scan the whole
> buffer pool, such as DROP TABLESPACE and DROP DATABASE.
>

If that is true, then our reliance on lseek elsewhere could also cause data
loss, for example by failing to scan data during a seq scan.

The consequences of failure of lseek in this case are nowhere near as dire,
since by definition the data is being destroyed by the user.

So ISTM that we should be able to use this technique.

--
Simon Riggs http://www.2ndQuadrant.com/
<http://www.2ndquadrant.com/>
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-06-28 16:17:18 Re: drop/truncate table sucks for large values of shared buffers
Previous Message Tom Lane 2015-06-28 15:46:42 Re: Semantics of pg_file_settings view