Re: Different results from identical matviews

From: Paul Förster <paul(dot)foerster(at)gmail(dot)com>
To: Michael Lewis <mlewis(at)entrata(dot)com>
Cc: Anders Steinlein <anders(at)e5r(dot)no>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Different results from identical matviews
Date: 2020-07-02 13:08:12
Message-ID: 2553D145-15CC-4A52-A8B9-850A1650F8F7@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Michael,

> On 02. Jul, 2020, at 14:55, Michael Lewis <mlewis(at)entrata(dot)com> wrote:
>
> Is now() computed at the time the view is defined and not at refresh? If this were a function, I would be more suspicious of that but a plain view, surely not. I hope.

now() returns the time at the beginning of the transaction:

see: https://www.postgresql.org/docs/current/functions-datetime.html

If you want the time whenever you call the function, use clock_timestamp() instead. There's also a good article at:

https://www.cybertec-postgresql.com/en/postgresql-now-vs-nowtimestamp-vs-clock_timestamp/

Hope this helps.

Cheers,
Paul

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2020-07-02 13:44:49 Re: Different results from identical matviews
Previous Message Anders Steinlein 2020-07-02 13:06:58 Re: Different results from identical matviews