Re: Let-bindings in SQL statements

From: Marti Raudsepp <marti(at)juffo(dot)org>
To: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Let-bindings in SQL statements
Date: 2012-02-14 14:06:15
Message-ID: CABRT9RDNT_JZ5cGTUeHvjqicmQBOP0wUmiY=1XHxtszJS0Xpcg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Feb 11, 2012 at 12:42, Jasen Betts <jasen(at)xnet(dot)co(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2012-02-14 14:39:03 Re: [GENERA]: Postgresql-9.1.1 synchronous replication issue
Previous Message Albe Laurenz 2012-02-14 13:27:26 Re: Database denormalization