update inside function does not use the index

Поиск
Список
Период
Сортировка
От Johannes
Тема update inside function does not use the index
Дата
Msg-id 5649E075.5010507@posteo.de
обсуждение исходный текст
Ответы Re: update inside function does not use the index  (Adrian Klaver <adrian.klaver@aklaver.com>)
Re: update inside function does not use the index  (Thomas Kellerer <spam_eater@gmx.net>)
Список pgsql-general
Dear List,

I have problems with a self written function, which does not use the
index, which takes very long (500 ms per update).


The pl/pgsql function iterates over a select resultset with a cursor.
In every loop I execute an update with a where LIKE condition, which
relates to my current cursor position:

FOR i IN SELECT id, level_ids, path_names||'%' as path_names from x LOOP
update x set path_ids[i.level] = id where path_names like i.path_names;
RAISE NOTICE 'path_names : %', i.path_names;
END LOOP;



Calling the updates outside the function, they are very fast because
like 'a.b%' uses the index of the path field ( ~ 15 ms ).

Does anyone know how to fix that?
Thanks, Johannes


Вложения

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

Предыдущее
От: Melvin Davidson
Дата:
Сообщение: Re: can postgres run well on NFS mounted partitions?
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: update inside function does not use the index