Re: Does IMMUTABLE property propagate?
От | Greg Stark |
---|---|
Тема | Re: Does IMMUTABLE property propagate? |
Дата | |
Msg-id | 407d949e1003060645i408e0648te67dfd722172f76a@mail.gmail.com обсуждение исходный текст |
Ответ на | Does IMMUTABLE property propagate? (Petru Ghita <petrutz@venaver.info>) |
Ответы |
Re: Does IMMUTABLE property propagate?
|
Список | pgsql-sql |
<p>The immutable property had nothing to do with caching results. Postgres never caches the results of functions. The immutableproperty is used top determine if it's safe to use indexes or other plans that avoid evaluating an expression repeatedly.<p><blockquotetype="cite">On 6 Mar 2010 02:45, "Petru Ghita" <<a href="mailto:petrutz@venaver.info">petrutz@venaver.info</a>>wrote:<br /><br />-----BEGIN PGP SIGNED MESSAGE-----<br />Hash: SHA1<br /><br /> Given f1(x) as IMMUTABLE and f2(x) as IMMUTABLE, and f3(f1,f2) as<br /> IMMUTABLE, does the queryplanner cache the result of f3 and reuse it<br /> or if you want to get a little more speed you better explicitly define<br/> yourself f3 as IMMUTABLE?<br /><br /> I had an aggregate query like:<br /><br /> select id,<br /> sum(p1*f1(a)/f2(b)as r1,<br /> sum(p2*f1(a)/f2(b) as r2,<br /> ...<br /> sum(pn*f1(a)/f2(b) as rn<br /><br/> ...<br /> group by id;<br /><br /> Where f1(x) and f2(x) were defined as IMMUTABLE.<br /><br /> By the experimentsI ran looks like after defining a new function<br /> f3(a,b):= f1(a)/f2(b) and rewriting the query as:<br /><br/> select id,<br /> sum(p1*f3(a,b) as r1,<br /> sum(p2*f3(a,b) as r2,<br /> ...<br /> sum(pn*f3(a,b)as rn<br /><br /> ...<br /> group by id;<br /><br /> *Looks like* I got a little (5%) improvement in performanceof the<br /> query. Is there a way to find out if the function is re-evaluated each<br /> time?<br /> Is thisthe recommended way to proceed?<br /><br /> Thank you!<br /><br /> Petru Ghita<br /> -----BEGIN PGP SIGNATURE-----<br/> Version: GnuPG v1.4.9 (MingW32)<br /> Comment: Using GnuPG with Mozilla - <a href="http://enigmail.mozdev.org/"target="_blank">http://enigmail.mozdev.org/</a><br /><br /> iEYEARECAAYFAkuRwYQACgkQt6IL6XzynQTHEgCffi2QMWkkvTIsuglsanvcUyRB<br/> I+wAoKr22B7FJJVDCssGKGwB8zr4NjQG<br /> =V/BS<br />-----END PGP SIGNATURE-----<br /><font color="#888888"><br /><br /> --<br /> Sent via pgsql-sql mailing list (<a href="mailto:pgsql-sql@postgresql.org">pgsql-sql@postgresql.org</a>)<br/> To make changes to your subscription:<br /><a href="http://www.postgresql.org/mailpref/pgsql-sql"target="_blank">http://www.postgresql.org/mailpref/pgsql-sql</a><br /></font></blockquote>
В списке pgsql-sql по дате отправления: