Re: lazy_truncate_heap()

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: lazy_truncate_heap()
Date: 2009-01-06 13:48:15
Message-ID: 4963611F.5060901@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rob Richardson 2009-01-06 14:06:43 Is there a way to do an exact-match search on this list?
Previous Message Tom Lane 2009-01-06 13:48:06 Re: [HACKERS] ERROR: failed to find conversion function from "unknown" to text