Re: How to properly query lots of rows based on timestamps?

From: Thorsten Schöning <tschoening(at)am-soft(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to properly query lots of rows based on timestamps?
Date: 2020-08-30 14:00:21
Message-ID: 1891354231.20200830160021@am-soft.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Guten Tag Tom Lane,
am Samstag, 29. August 2020 um 17:19 schrieben Sie:

> Timestamp comparison reduces to comparison of int64's, so it's
> hard to imagine that anything could be much cheaper.[...]

Do you think it matters much if the timestamp related calculations are
done outside the query by the executing Java instead?

> ('2020-08-01 00:00:00+02'::timestamp with time zone - '00:00:00'::interval)

In Java, I currently only have the timestamp and the intervals as
ISO8601-expressions like P1D, P14D etc. and leave all of their parsing
to Postgres as much as possible. This results in calculations like the
above necessary before actually comparing against stored timestamps.

I would expect that it doesn't make much difference if Postgres or
Java calculate the necessary timestamps. As long as Postgres is clever
enough to NOT calculate by row, but only once instead? Which I guess
it is? Is there any hint to such things in the plan? I didn't see or
understood them.

Mit freundlichen Grüßen,

Thorsten Schöning

--
Thorsten Schöning E-Mail: Thorsten(dot)Schoening(at)AM-SoFT(dot)de
AM-SoFT IT-Systeme http://www.AM-SoFT.de/

Telefon...........05151- 9468- 55
Fax...............05151- 9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow

In response to

Browse pgsql-general by date

  From Date Subject
Next Message ERR ORR 2020-08-30 14:31:38 Request clarification w/ PG_DUMPALL -d.
Previous Message Thorsten Schöning 2020-08-30 13:54:11 Re: How to properly query lots of rows based on timestamps?