Re: combination of function to simple query makes query slow

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: combination of function to simple query makes query slow
Дата
Msg-id 8195.1128437407@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: combination of function to simple query makes query slow  ("jan aerts (RI)" <jan.aerts@bbsrc.ac.uk>)
Список pgsql-sql
"jan aerts (RI)" <jan.aerts@bbsrc.ac.uk> writes:
> My Postgres version is 7.3.4 (on a central server, so I can't upgrade if
> that would be one of the suggestions...)

7.3.4 has multiple known data-loss bugs and security issues.  If you're
dealing with someone who won't upgrade it, find someone else to deal
with.  At the very least they need to move to 7.3.10 (or as of today,
7.3.11).  See
http://developer.postgresql.org/docs/postgres/release-7-3-11.html
and following pages for reasons why.

> I thought that making a function stable or immutable would make it
> available for an index search.

Your problem isn't the function, it's the IN (SELECT ...) construct.
7.3 is not bright enough to optimize that.  (Given that it's a
correlated sub-SELECT, I'm afraid later releases aren't either :-(.)
You need to find a way of expressing the query without that.

My guess is that trying to use a function for this is counterproductive
in itself; the table access that's going on inside the function needs
to be exposed for optimization in order to get reasonable overall
performance.
        regards, tom lane


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

Предыдущее
От: "jan aerts (RI)"
Дата:
Сообщение: Re: combination of function to simple query makes query slow
Следующее
От: solarsail
Дата:
Сообщение: using pg_tables and tablename in queries