Re: Very newbie question

Поиск
Список
Период
Сортировка
Искать
От
Олег Самойлов
Тема
Re: Very newbie question
Дата
Msg-id
50F00665-2AB4-409C-9445-5E32482C0FA4@ya.ru
Ответ на
Very newbie question (Олег Самойлов)
Список
Дерево обсуждения
Very newbie question Олег Самойлов <splarv@ya.ru>
Re: Very newbie question Олег Самойлов <splarv@ya.ru>
Re: Very newbie question Olivier Gautherot <ogautherot@gautherot.net>
Re: Very newbie question "Peter J. Holzer" <hjp-pgsql@hjp.at>
Re: Very newbie question Olivier Gautherot <ogautherot@gautherot.net>
Re: Very newbie question "Peter J. Holzer" <hjp-pgsql@hjp.at>
Re: Very newbie question Ron <ronljohnsonjr@gmail.com>
Re: Very newbie question Toomas <toomas.kristin@gmail.com>
Re: Very newbie question Олег Самойлов <splarv@ya.ru>
Re: Very newbie question Francisco Olarte <folarte@peoplecall.com>
Re: Very newbie question Олег Самойлов <splarv@ya.ru>
Re: Very newbie question Francisco Olarte <folarte@peoplecall.com>
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.

Original query was:

> 23 окт. 2023 г., в 18:13, Олег Самойлов  написал(а):
> 
> SELECT id/10000000 as partition
>   FROM delivery
>   GROUP BY partition
>   HAVING max(created_at) < CURRENT_DATE - '3 month'::interval;

And I was not able to accelerate it by any index, works 5 minutes. 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.

В списке pgsql-general по дате отправления
От: Bruce Momjian
Дата:
Сообщение: Re: REINDEX in tables
От: John W Higgins
Дата:
FAQ