function performs differently with different values

Поиск
Список
Период
Сортировка
От Ben Chobot
Тема function performs differently with different values
Дата
Msg-id 3BA4A0CF-11CE-4165-A97C-88FB1607EF87@silentmedia.com
обсуждение исходный текст
Ответы Re: function performs differently with different values  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-performance
I've got a sql language function which does a fairly simple select from a table. If I give it one value, it performs
quickly(half a ms). If I give it another value, it does not (1.1 seconds). When I run the equivalent select outside of
thefunction, both values perform roughly the same (even though one value returns 140k more rows, as expected).  

My understanding is that this generally happens because the plan should be different for the different values, but the
firsttime the function is run it caches the plan for one of the values and will never use the appropriate plan for the
secondvalue. However, when I do an explain analyze of the raw sql for both values, I get the same plan. So my
understandingmust be wrong? 

I suppose the other possibility is that the slower value is slower in a function because it's returning 140k more rows
andthe function has to deal with that additional data..... but that seems far-fetched, given that each row is just an
int.

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

Предыдущее
От: Krzysztof Kardas
Дата:
Сообщение: Re: PostgreSQL with Zabbix - problem of newbe
Следующее
От: Greg Smith
Дата:
Сообщение: Re: About “context-switching issue on Xeon” test case ?