Re: Why is the comparison between timestamp and date so much slower then between two dates

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Why is the comparison between timestamp and date so much slower then between two dates
Date: 2016-04-13 13:45:22
Message-ID: 20237.1460555122@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thomas Kellerer <spam_eater(at)gmx(dot)net> writes:
> So my question is: why is comparing a timestamp to a date so much slower?

The date has to be up-converted to a timestamptz (not timestamp).
I think the expensive part of that is determining what timezone
applies, in particular whether DST is active. You could try it
with "localtimestamp" (no parens) instead of "now()" to see how
it performs with a non-tz timestamp.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Edson Richter 2016-04-13 13:58:17 Re: Fastest way to duplicate a quite large database
Previous Message Thomas Kellerer 2016-04-13 12:16:50 Why is the comparison between timestamp and date so much slower then between two dates