Re: drop/truncate table sucks for large values of shared buffers - Mailing list pgsql-hackers

From Amit Kapila
Subject Re: drop/truncate table sucks for large values of shared buffers
Date
Msg-id CAA4eK1+=N+gsVc=w7nLFWz3odmEHY003wWS_=xbvXVm8XUQDSw@mail.gmail.com
Whole thread Raw
In response to Re: drop/truncate table sucks for large values of shared buffers  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: drop/truncate table sucks for large values of shared buffers
List pgsql-hackers
On Sat, Jun 27, 2015 at 7:40 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Amit Kapila <amit.kapila16@gmail.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?)

Considering we already have exclusive lock while doing this operation
and nobody else can perform write on this file, won't closing and
opening it again would avoid such problems.  In patch that is already
done (smgrexists()) for 2 kind of forks and can be done for the third kind
as well.

>  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.
>

True, but it is not foreclosing if any body has idea to optimize those
paths.


With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Solaris testers wanted for strxfrm() behavior
Next
From: Tatsuo Ishii
Date:
Subject: Re: pg_file_settings view vs. Windows