Re: Let-bindings in SQL statements - Mailing list pgsql-general

From Marti Raudsepp
Subject Re: Let-bindings in SQL statements
Date
Msg-id CABRT9RDNT_JZ5cGTUeHvjqicmQBOP0wUmiY=1XHxtszJS0Xpcg@mail.gmail.com
Whole thread Raw
In response to Re: Let-bindings in SQL statements  (Jasen Betts <jasen@xnet.co.nz>)
List pgsql-general
On Sat, Feb 11, 2012 at 12:42, Jasen Betts <jasen@xnet.co.nz> wrote:
> There is no need. now() is tagged as stable. it will only be executed once.
> the planner will figure this out for you.

Actually that's not always true. In index condition arguments, the
expression would indeed be executed just once. But in filter clauses
(e.g. seq scan), the whole expression is executed once per row, which
is a bit inefficient. Of course this makes no visible difference for
now(), since it always returns the same value -- the transaction start
time.

(I submitted a patch to improve this, but it's not certain whether it
will be included in PostgreSQL 9.2 or not)

Regards,
Marti

pgsql-general by date:

Previous
From: "Albe Laurenz"
Date:
Subject: Re: Database denormalization
Next
From: Adrian Klaver
Date:
Subject: Re: [GENERA]: Postgresql-9.1.1 synchronous replication issue