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 1s6uno-002Rof-J8 for pgsql-general@arkaria.postgresql.org; Tue, 14 May 2024 16:14:57 +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 1s6uno-00H3MM-Dm for pgsql-general@arkaria.postgresql.org; Tue, 14 May 2024 16:14:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s6uno-00H3ME-0b for pgsql-general@lists.postgresql.org; Tue, 14 May 2024 16:14:56 +0000 Received: from mout.gmx.net ([212.227.17.20]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s6unk-000DXR-LW for pgsql-general@lists.postgresql.org; Tue, 14 May 2024 16:14:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1715703291; x=1716308091; i=jimis@gmx.net; bh=hgBAY9f3fEntRJdx/p+yE96N1Pn57KYH8TlqLRSzfQk=; h=X-UI-Sender-Class:Date:From:To:cc:Subject:In-Reply-To:Message-ID: References:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=bocthHkWzjAKFx3EMs075G+EOHuuV1esDieHFAfhKj/BfyCJ4mceRTUD9hTChxPb 7+GubbMd/Fo8T9RTisDXL2rg8IIAmzDuza1IOZDrNZsSc6Kh0j1CgI7hvWuhCj6Cp r+iA+h7sINtU032lAk2aPcja3qOsQP7lk+Tl1rhS0GfgtzqWiFQsDGeIRA8EZq/la z5+/dCVuUys6hJ0sI0EZEnU7LzQU8/65LTFWdyMoHZojItD0ZfgCPImMynbOsDNmU /WTdjUG6q2zOAnGU8GtJC1zJi1CV/y7MBetwr+5PP6vZTVsGW+VrzemaarZc2JlbB 8/kmEBoQ2u4C2SCP6w== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [10.9.70.35] ([185.55.106.54]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MdNcG-1sfyVH0P4a-00ZMWG; Tue, 14 May 2024 18:14:51 +0200 Date: Tue, 14 May 2024 18:14:45 +0200 (CEST) From: Dimitrios Apostolou To: Tom Lane cc: pgsql-general@lists.postgresql.org, David Rowley Subject: Re: SELECT DISTINCT chooses parallel seqscan instead of indexscan on huge table with 1000 partitions In-Reply-To: <660a8477-4130-40da-3492-f8827c5c3596@gmx.net> Message-ID: <5dfcb84a-2d32-8dde-772b-4305a7468774@gmx.net> References: <7886a68f-b466-2131-1747-f69f0fb71a37@gmx.net> <69077f15-4125-2d63-733f-21ce6eac4f01@gmx.net> <559b0e40-63e6-fa9a-6b03-d1eba10f30f8@gmx.net> <1629463.1715372568@sss.pgh.pa.us> <660a8477-4130-40da-3492-f8827c5c3596@gmx.net> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Provags-ID: V03:K1:PnurJ10ug243iFKNrS90Wjds0xfFhIBBmJtbCp3W0SKht6sb56y Xw/HXGqPrUvybT56sfjcSio4Q77owWlSz1gF+ZWHqY+Su9VtB/WdrwLn6VngTSA36dCiZ+q /IhGrvKKKLhTsPdvVsVTwP7OqB20QElby3xC+RXiLgUsZwe3RFxnlNIJ3REUfw5UtTVJVZu GwMZRbj33dxdYCOJYznWA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:LoBn59Tg0YI=;jpuuIBuU3ocLgDeNGU/kcEng3sg SQL3ekVad6i6xjGjdeiS+va90eV5T3hdT8F5OkW7tcEKBfCiE313I3EBEkUOSLSr5127ND4YN 5bSYiw2vfC3gfQUqyFr2/QUKMkqUaTpvrqEioTaBgwb9JczAtqT7Yw8RMYt/agTj0rjk8W1aQ tURnReVI1Zh8xpODJf2xjTplgzPzxDU/e+7ih6AGDCo+3KlRboM4VoEbBShEvFGEbwlXPYRyv bk04klNGjyV/K+G9R2SjCTXD7wawznlnR6+ivaYuNVjWuCHMl0ZKpukZuhaGeKarOz2m3ifBD bHF1t8Scvhz2lUB95vCtt7SjlDmR5yT2/Y0c66Fy2+qC5bkfS2J69OSkfYZd4YA7tuHQ1vVsW kHIzCqfis7QFCOkQZw8PkMgMKU3rhAR+YbEymrLHi+0swfvvGBHH7IN9kx17+p+uUUTGxgd/m R3z6ODWKiHGpjd3eoBqCwgo4eb70saTa1Mb1cPRiak7AUKQ7luq8TDYMsnumRgJ65/yeCShtI DsYPOQhpQg5JpacB12iNvZK6SE1L51tXT9nPbG+AMQ7T9isPBzvXBNIxqrSWcC1AHvRIO+iJR MqmKrqIJiljBJJUWMMsc+AOaiJTodu6UmSTlIoyonUmiD5kTy3EzP0cl6i5YyJ9VFeHRsd87P Zx0LLT5++Vpl6WDU4U86fQx8Iim1TnXcMq2DVO38z3b2Lu2kg50fyWYEfunpR9vRkqgap1Tei XFwWv4DRLVEmFYXTDenViccrpGw/JTDj3F0axT784B8aD1FKkhSBnoVWNo/ZtzQbc+A8xg9/e jTkVGC+/8epeA6+3Ege067lVXdpDEsweEuRAbmf7OdRl0= Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 14 May 2024, Dimitrios Apostolou wrote: > > It took long but if finished: > > ANALYZE > Time: 19177398.025 ms (05:19:37.398) I see now that default_statistics_target is globally set to 500, so this is probably the reason it took so long. I guess with the default of 100, it would take approximately one hour. This is much better to have in a cron job. :-) Dimitris