Re: Interesting case of IMMUTABLE significantly hurting performance
От | Tom Lane |
---|---|
Тема | Re: Interesting case of IMMUTABLE significantly hurting performance |
Дата | |
Msg-id | 22812.1376453860@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Interesting case of IMMUTABLE significantly hurting performance (Craig Ringer <craig@2ndquadrant.com>) |
Ответы |
Re: Interesting case of IMMUTABLE significantly hurting
performance
|
Список | pgsql-performance |
Craig Ringer <craig@2ndquadrant.com> writes: > I've run into an interesting Stack Overflow post where the user shows > that marking a particular function as IMMUTABLE significantly hurts the > performance of a query. > http://stackoverflow.com/q/18220761/398670 > CREATE OR REPLACE FUNCTION > to_datestamp_immutable(time_int double precision) RETURNS date AS $$ > SELECT date_trunc('day', to_timestamp($1))::date; > $$ LANGUAGE SQL IMMUTABLE; [ shrug... ] Using IMMUTABLE to lie about the mutability of a function (in this case, date_trunc) is a bad idea. It's likely to lead to wrong answers, never mind performance issues. In this particular case, I imagine the performance problem comes from having suppressed the option to inline the function body ... but you should be more worried about whether you aren't getting flat-out bogus answers in other cases. regards, tom lane
В списке pgsql-performance по дате отправления: