From: | Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz> |
---|---|
To: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Seref Arikan <serefarikan(at)kurumsalteknoloji(dot)com>, PG-General Mailing List <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Does it make sense to break a large query into separate functions? |
Date: | 2013-05-08 21:47:58 |
Message-ID: | 518AC80E.3090503@archidevsys.co.nz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 09/05/13 09:35, Merlin Moncure wrote:
[...]
> More oddness -- when I wrap, say, random() with stable function, I get
> unique value per returned row, but same value across the set when
> wrapped with immutable.
[..]
That part I think I know (but, I'm often wrong!).
By saying it is immutable, you are saying that the values returned for
the same set of parameters is always the same. The system looks at your
immutable function that wraps random() and 'knows' that once invoked,
the value returned will always be the same, so why would it want to
invoke your immutable function multiple times, as it can just do that
once and reuse the value returned?
Cheers,
Gavin
From | Date | Subject | |
---|---|---|---|
Next Message | Jon Smark | 2013-05-08 23:03:45 | Normal errors codes in serializable transactions |
Previous Message | Bruce Momjian | 2013-05-08 21:35:12 | Re: [GENERAL] pg_upgrade fails, "mismatch of relation OID" - 9.1.9 to 9.2.4 |