From: Niels Jespersen <NJN@dst.dk>
To: Francisco Olarte <folarte@peoplecall.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Ron <ronljohnsonjr@gmail.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: SV: where clauses including timstamptz and intervals
Date: Fri, 16 Apr 2021 06:01:04 +0000
Message-ID: <7fa490f5d64749bd92ba1f78c0c6b80e@dst.dk> (raw)
In-Reply-To: <CA+bJJbxz5FCGf0RQE52dmCMf8jVquuBR-dJ7R9FxOXSMrJbiDA@mail.gmail.com>
References: <df95450aee764d6fbedaf04613d17508@dst.dk>
<20210409102400.GA2310@depesz.com>
<21887e8a-a9aa-d858-8c78-0a97a44c800a@gmail.com>
<2198582.1617985392@sss.pgh.pa.us>
<a98ca0f0da1d4aa68549461133aad47b@dst.dk>
<CA+bJJbxz5FCGf0RQE52dmCMf8jVquuBR-dJ7R9FxOXSMrJbiDA@mail.gmail.com>
>-----Oprindelig meddelelse-----
>Fra: Francisco Olarte <folarte@peoplecall.com>
>Sendt: 10. april 2021 09:31
>Til: Niels Jespersen <NJN@dst.dk>
>
>Although it is equivalent I would suggest to use:
>
>f.r_time< ('2020-10-01 00:00:00+00'::timestamptz at time zone 'utc' + interval '1 month') at time zone 'utc' ;
>
>optimizer should treat both the same, but I'm no sure it can recognize it, and it may not see your condition is of the type "field < constant" to select index scans and similar things. Also, you can refactor your calculations into an stable function for greater clarity.
The plannes seems to be able to figure this out nicely.
>
>> I think maybe it's better to just change the session timezone when this need arises.
>
>Maybe. Also, I do not see the need to query exact partitions by tstz range, but assuming you do it may be much easier to query the catalog for the partition and then query the partition. ( In many years of working with time-partitioned tables I have never got the need to build a query to hit exactly X partitions from times ).
>
I need to hit an exact partition, because the query makes some QA on data coming from a file that fits that exact timeslot. File and partition must match exactly because the file may be raplaced later and the partition truncated.
Thank you for your insights.
Niels
>Francisco Olarte.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: NJN@dst.dk, folarte@peoplecall.com, tgl@sss.pgh.pa.us, ronljohnsonjr@gmail.com
Subject: Re: where clauses including timstamptz and intervals
In-Reply-To: <7fa490f5d64749bd92ba1f78c0c6b80e@dst.dk>
References: <df95450aee764d6fbedaf04613d17508@dst.dk> <20210409102400.GA2310@depesz.com> <21887e8a-a9aa-d858-8c78-0a97a44c800a@gmail.com> <2198582.1617985392@sss.pgh.pa.us> <a98ca0f0da1d4aa68549461133aad47b@dst.dk> <CA+bJJbxz5FCGf0RQE52dmCMf8jVquuBR-dJ7R9FxOXSMrJbiDA@mail.gmail.com> <7fa490f5d64749bd92ba1f78c0c6b80e@dst.dk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox