From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: Very newbie question
Date: Thu, 26 Oct 2023 11:15:00 +0200
Message-ID: <20231026091500.5g5iwjadoljcxbot@hjp.at> (raw)
In-Reply-To: <CAJ7S9TX4z3cOvD4PVFFH73qC2qwr+o1QoF=ERLVQJpy0u+De5A@mail.gmail.com>
References: <B3F74121-CECE-42D2-B0AB-5D7E6F3A466A@ya.ru>
<50F00665-2AB4-409C-9445-5E32482C0FA4@ya.ru>
<CAJ7S9TX4z3cOvD4PVFFH73qC2qwr+o1QoF=ERLVQJpy0u+De5A@mail.gmail.com>
On 2023-10-25 17:48:46 +0200, Olivier Gautherot wrote:
> El mié, 25 oct 2023 16:58, Олег Самойлов <splarv@ya.ru> escribió:
> Okey, I see no one was be able to solve this problem. But I could. May be
> for someone this will be useful too. There is solution.
[...]
> Now query is:
>
> SELECT generate_series(min(id)/10000000, max(id)/10000000) AS n FROM
> delivery) as part_numbers
> WHERE (SELECT max(created_at) from delivery where n*10000000 <=id
> and id < (n+1)*10000000)
> < CURRENT_DATE-'3 month'::interval;
>
> Return the same (number of partition need to archive), accelerated by two
> btree index: on id and created_at. Works very quick, less then second.
[...]
> Your fast solution will work as long as you don't have missing sequences (like
> deleted rows).
Why do you think this would break with missing sequence numbers?
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
Attachments:
signature.asc (application/pgp-signature, 832B) download
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: hjp-pgsql@hjp.at
Subject: Re: Very newbie question
In-Reply-To: <20231026091500.5g5iwjadoljcxbot@hjp.at>
References: <B3F74121-CECE-42D2-B0AB-5D7E6F3A466A@ya.ru> <50F00665-2AB4-409C-9445-5E32482C0FA4@ya.ru> <CAJ7S9TX4z3cOvD4PVFFH73qC2qwr+o1QoF=ERLVQJpy0u+De5A@mail.gmail.com> <20231026091500.5g5iwjadoljcxbot@hjp.at>
* 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