pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Craig Ringer <craig@2ndquadrant.com>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Interesting case of IMMUTABLE significantly hurting performance
Date: Wed, 14 Aug 2013 00:17:40 -0400
Message-ID: <22812.1376453860@sss.pgh.pa.us> (raw)
In-Reply-To: <520AD240.9060508@2ndquadrant.com>
References: <520AD240.9060508@2ndquadrant.com>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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


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



view thread (7+ messages)  latest in thread

Message-ID: <22812.1376453860@sss.pgh.pa.us>
Permalink:  ../22812.1376453860@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/22812.1376453860@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, craig@2ndquadrant.com
  Subject: Re: Interesting case of IMMUTABLE significantly hurting performance
  In-Reply-To: <22812.1376453860@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox