pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Toomas <toomas.kristin@gmail.com>
To: Олег Самойлов <splarv@ya.ru>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Very newbie question
Date: Mon, 23 Oct 2023 18:23:33 +0300
Message-ID: <AC086CDE-EA2A-41E3-A5BA-9D858BE5783B@gmail.com> (raw)
In-Reply-To: <B3F74121-CECE-42D2-B0AB-5D7E6F3A466A@ya.ru>
References: <B3F74121-CECE-42D2-B0AB-5D7E6F3A466A@ya.ru>


There is no reason to use index. The query has neither WHERE nor ORDER BY clause.

Toomas

> On 23. Oct 2023, at 18:13, Олег Самойлов <splarv@ya.ru> wrote:
> 
> Back pardon, but I have a very newbie question. I have a partitioned table, partitioned by primary bigint key, size of partition 10000000. I need to get the number of partition which need to archive, which has all rows are olden then 3 month. Here is query:
> 
> SELECT id/10000000 as partition
>   FROM delivery
>   GROUP BY partition
>   HAVING max(created_at) < CURRENT_DATE - '3 month'::interval;
> 
> The 'id/10000000 as partition' is a number of the partition, it later will be used inside the partition name.
> The query runs long by sequence scan. Has anyone any ideas how to rewrite query so it will use any index?
> 






view thread (12+ messages)  latest in thread

Message-ID: <AC086CDE-EA2A-41E3-A5BA-9D858BE5783B@gmail.com>
Permalink:  ../AC086CDE-EA2A-41E3-A5BA-9D858BE5783B@gmail.com/
Also on:    postgresql.org/message-id/AC086CDE-EA2A-41E3-A5BA-9D858BE5783B@gmail.com

 · 

reply

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: toomas.kristin@gmail.com, splarv@ya.ru
  Subject: Re: Very newbie question
  In-Reply-To: <AC086CDE-EA2A-41E3-A5BA-9D858BE5783B@gmail.com>
  References: <B3F74121-CECE-42D2-B0AB-5D7E6F3A466A@ya.ru> <AC086CDE-EA2A-41E3-A5BA-9D858BE5783B@gmail.com>

* 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