Обсуждение: Missed bet in toaster routines

Поиск
Список
Период
Сортировка

Missed bet in toaster routines

От
Tom Lane
Дата:
Wouldn't it be a win for heap_tuple_toast_attrs() to fall out quickly
if the tuple contains no varlena attributes?  I'm thinking of adding
a test like
/* Nothing to do if tuple contains no varlena fields */if ((newtup && !HeapTupleAllFixed(newtup)) ||    (oldtup &&
!HeapTupleAllFixed(oldtup)))   /* do existing processing */
 

This is a pretty cheap test (just checking a header flag) and saves lots
of useless scanning when it succeeds.
        regards, tom lane


Re: Missed bet in toaster routines

От
Jan Wieck
Дата:
Tom Lane wrote:
> Wouldn't it be a win for heap_tuple_toast_attrs() to fall out quickly
> if the tuple contains no varlena attributes?  I'm thinking of adding
> a test like
> 
>     /* Nothing to do if tuple contains no varlena fields */
>     if ((newtup && !HeapTupleAllFixed(newtup)) ||
>         (oldtup && !HeapTupleAllFixed(oldtup)))
>         /* do existing processing */
> 
> This is a pretty cheap test (just checking a header flag) and saves lots
> of useless scanning when it succeeds.

Why sure it would. That code is quite frequently called.


Jan

-- 
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #



Re: Missed bet in toaster routines

От
Tom Lane
Дата:
Jan Wieck <JanWieck@Yahoo.com> writes:
> Tom Lane wrote:
>> Wouldn't it be a win for heap_tuple_toast_attrs() to fall out quickly
>> if the tuple contains no varlena attributes?

> Why sure it would. That code is quite frequently called.

I take it back --- the short-circuit test already exists, but it's at
the call sites rather than in tuptoaster.c.

However, it looks like we can tighten the tests a bit.  For instance
heap_delete invokes the toaster if HeapTupleHasExtended, whereas it
seems to me it'd be sufficient to check HasExternal --- we don't care
about deleting compressed-in-line stuff, do we?
        regards, tom lane