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