Re: How to properly query lots of rows based on timestamps? - Mailing list pgsql-general

From Thorsten Schöning
Subject Re: How to properly query lots of rows based on timestamps?
Date
Msg-id 1891354231.20200830160021@am-soft.de
Whole thread Raw
In response to Re: How to properly query lots of rows based on timestamps?  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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.Schoening@AM-SoFT.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




pgsql-general by date:

Previous
From: Thorsten Schöning
Date:
Subject: Re: How to properly query lots of rows based on timestamps?
Next
From: ERR ORR
Date:
Subject: Request clarification w/ PG_DUMPALL -d.