equal() perf tweak

Поиск
Список
Период
Сортировка
От Neil Conway
Тема equal() perf tweak
Дата
Msg-id 1067868034.3089.225.camel@tokyo
обсуждение исходный текст
Ответы Re: equal() perf tweak  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-patches
Currently, equal() does the following for List nodes:

case T_List:
{
    List       *la = (List *) a;
    List       *lb = (List *) b;
    List       *l;

    /*
     * Try to reject by length check before we grovel through
     * all the elements...
     */
    if (length(la) != length(lb))
        return false;
    foreach(l, la)
    {
        if (!equal(lfirst(l), lfirst(lb)))
            return false;
        lb = lnext(lb);
    }
    retval = true;
}
break;

This code is inefficient, however: length() requires iterating through
the entire list, so this code scans both lists twice. The attached patch
improves this by implementing equal() with a single scan of both lists.

-Neil


Вложения

В списке pgsql-patches по дате отправления:

Предыдущее
От: Jan Wieck
Дата:
Сообщение: Re: bufmgr code cleanup
Следующее
От: Tom Lane
Дата:
Сообщение: Re: bufmgr code cleanup