Re: lazy_truncate_heap() - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: lazy_truncate_heap()
Date
Msg-id 4963611F.5060901@enterprisedb.com
Whole thread Raw
In response to Re: lazy_truncate_heap()  (Simon Riggs <simon@2ndQuadrant.com>)
Responses Re: lazy_truncate_heap()  (Simon Riggs <simon@2ndQuadrant.com>)
List pgsql-hackers
Simon Riggs wrote:
> On Wed, 2008-12-31 at 21:45 +0200, Heikki Linnakangas wrote:
>>> Can I fix?
>> Yes please.
> 
> Fix attached.

> --- 183,192 ----
>        * number of pages.  Otherwise, the time taken isn't worth it.
>        */
>       possibly_freeable = vacrelstats->rel_pages - vacrelstats->nonempty_pages;
> !     if (vacrelstats->tuples_deleted > 0 &&
> !         (possibly_freeable >= REL_TRUNCATE_MINIMUM ||
> !          (possibly_freeable >= vacrelstats->rel_pages / REL_TRUNCATE_FRACTION &&
> !           possibly_freeable > 0)))
>           lazy_truncate_heap(onerel, vacrelstats);
>   

Where did that "tuples_deleted > 0" condition come from? It seems 
counter-productive; if a previous vacuum failed to acquire the lock, 
subsequent vacuums wouldn't even try if they don't remove any tuples. 
How about simply:

***************
*** 183,190 ****       * number of pages.  Otherwise, the time taken isn't worth it.       */      possibly_freeable =
vacrelstats->rel_pages- 
 
vacrelstats->nonempty_pages;
!     if (possibly_freeable >= REL_TRUNCATE_MINIMUM ||
!         possibly_freeable >= vacrelstats->rel_pages / REL_TRUNCATE_FRACTION)          lazy_truncate_heap(onerel,
vacrelstats);
      /* Vacuum the Free Space Map */
--- 183,191 ----       * number of pages.  Otherwise, the time taken isn't worth it.       */      possibly_freeable =
vacrelstats->rel_pages- 
 
vacrelstats->nonempty_pages;
!     if (possibly_freeable > 0 &&
!         (possibly_freeable >= REL_TRUNCATE_MINIMUM ||
!          possibly_freeable >= vacrelstats->rel_pages / REL_TRUNCATE_FRACTION))          lazy_truncate_heap(onerel,
vacrelstats);
      /* Vacuum the Free Space Map */


--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [GENERAL] ERROR: failed to find conversion function from "unknown" to text
Next
From: Simon Riggs
Date:
Subject: Re: lazy_truncate_heap()