Re: Interesting case of IMMUTABLE significantly hurting performance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Craig Ringer <craig@xxxxxxxxxxxxxxx> 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


-- 
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux