Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1quwmQ-002Ft8-SF for pgsql-general@arkaria.postgresql.org; Mon, 23 Oct 2023 15:23:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1quwmO-00Aqpb-Pf for pgsql-general@arkaria.postgresql.org; Mon, 23 Oct 2023 15:23:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1quwmO-00AqoH-EO for pgsql-general@lists.postgresql.org; Mon, 23 Oct 2023 15:23:45 +0000 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1quwmM-001vLl-K3 for pgsql-general@lists.postgresql.org; Mon, 23 Oct 2023 15:23:43 +0000 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-32dd70c5401so2395648f8f.0 for ; Mon, 23 Oct 2023 08:23:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698074620; x=1698679420; darn=lists.postgresql.org; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=wVfHGE6h8x+WrCWQJmlYAZ6rD52imGgd7RApKZ6AFV8=; b=DyXMulKRPnb2JJyKzuWmi7wpuowkAkXHpmA0xOYHuM7WnpNjUZhUfcVlTsLtSzpSiW +tyjiQh4fwCZWfsEu999EkW0vtcDWMnIi66V/3n8R/2jWHX8LgukLKkuY2F/L4t+vQ8A dVBn1Dvq8hc9W3Y423FcuDwXlpoFjUKiL20HFU81MBpCvahN9FFdkmgM2t5pBx+7ceNE 3A494K+dRhWPya0Q/w54ANBKwavXaSCCbWj7fd3dZDwTqRv+iPhn0LMkHxZev/IZo/mk K7+GKANux3M+HhIQt1axQ5zCZYpFwx7cx1yRztbEKa5huFbOEnuLHv8WwhIWG9M1iIYt yQJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698074620; x=1698679420; h=message-id:in-reply-to:to:references:date:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wVfHGE6h8x+WrCWQJmlYAZ6rD52imGgd7RApKZ6AFV8=; b=SDzeRqeeL9W3Nm6do1y9cG4jaP7hdatBDKWB937hjI91G5aKfBvH2mxKKgc1YscK4H /hM+19JQ1FgxDYz8JoD/I/7BHfY3FvGeim/chyBoWs++jPvsdUprrDJGZdZkAmrNwEnG LJk+P7Xe6+6UXkbLEq38rCu+Pbixw28lXvqgHUNMwZ4J53y0tMWMUZ2c4jGGcNtew3t5 P9o6IcecfR24c8CGAApOF4Nb6jj6FVCip/MwIzUPCRXhzrP2GBB1wMsMZFww+NujdRko 3nZ+hyeNXlHbCleNunGo58XL/nGrWsMK/npl3TKY4pM7Ny0U5OWhyGLm/ZaMcNYTPqFZ FxUg== X-Gm-Message-State: AOJu0Yx+Te11qlP9+ygpj+BiJSwhgCwXCjo2qfDiu8ya+5NPUHI5u2Tw 2+nn714wO3g9zag43qowHSI= X-Google-Smtp-Source: AGHT+IFmLERgCX4PlWiw/yBCoHtRlsmEYfL91cNfhQ4qJ1mevLfcHfhW4S2WXITpRzNSCMYBlnWdqg== X-Received: by 2002:a5d:460b:0:b0:320:920:42b1 with SMTP id t11-20020a5d460b000000b00320092042b1mr6366887wrq.53.1698074620014; Mon, 23 Oct 2023 08:23:40 -0700 (PDT) Received: from smtpclient.apple (ec2-3-249-47-104.eu-west-1.compute.amazonaws.com. [3.249.47.104]) by smtp.gmail.com with ESMTPSA id l9-20020a5d5609000000b0032da7454ebesm7982482wrv.79.2023.10.23.08.23.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2023 08:23:39 -0700 (PDT) From: Toomas Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Re: Very newbie question Date: Mon, 23 Oct 2023 18:23:33 +0300 References: To: =?utf-8?B?0J7Qu9C10LMg0KHQsNC80L7QudC70L7Qsg==?= , "pgsql-general@lists.postgresql.org" In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.3731.700.6) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk There is no reason to use index. The query has neither WHERE nor ORDER = BY clause. Toomas > On 23. Oct 2023, at 18:13, =D0=9E=D0=BB=D0=B5=D0=B3 =D0=A1=D0=B0=D0=BC=D0= =BE=D0=B9=D0=BB=D0=BE=D0=B2 wrote: >=20 > 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: >=20 > SELECT id/10000000 as partition > FROM delivery > GROUP BY partition > HAVING max(created_at) < CURRENT_DATE - '3 month'::interval; >=20 > 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? >=20