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 1s6Ump-00CL7z-DF for pgsql-general@arkaria.postgresql.org; Mon, 13 May 2024 12:28:11 +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 1s6Umn-000bNn-Og for pgsql-general@arkaria.postgresql.org; Mon, 13 May 2024 12:28:10 +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 1s6Umn-000bN0-Be for pgsql-general@lists.postgresql.org; Mon, 13 May 2024 12:28:09 +0000 Received: from mout.gmx.net ([212.227.17.21]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s6Umk-000o70-RM for pgsql-general@lists.postgresql.org; Mon, 13 May 2024 12:28:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1715603283; x=1716208083; i=jimis@gmx.net; bh=E9Azek+UhhLIzuryEQRcypP08P9hCUZIuODs9bFUyyM=; 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=ZM5abBcbjSaFAYsVjfHbbQ0jKmCT4uDWW69mYIe7Q/xaliycI/3Xwg+c0T+HIJnu imEzekla7ZFPYC6CdBr4goZJcf2e8Iye9g8xCkDwYdak/azEKNojmq0UE7ZfDGJFD OOxhrXy6B5BYnkg7yD9hz+cprHjQ5FIxOXu4kJaZmKYuglQs20/oNlyxjzHEpVmu0 o5jAKFcmstU2MSCOV5O2A6SpvOFj2vz8g0jIcsl1xMsm08CizvVA9DhOpDBt4KXvA nlYuJ71aOzAr/DceNy8yhakodM9DRfajpnbCq3FW8FDY63UvkQO8bI+ukouuo/5Ip jA/2PGXfGm0FVwGTBg== 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 1MKKUp-1rrzVU0qtj-00LoZc; Mon, 13 May 2024 14:28:03 +0200 Date: Mon, 13 May 2024 14:27:57 +0200 (CEST) From: Dimitrios Apostolou To: David Rowley cc: Tom Lane , pgsql-general@lists.postgresql.org Subject: Re: SELECT DISTINCT chooses parallel seqscan instead of indexscan on huge table with 1000 partitions In-Reply-To: Message-ID: <2e3947bd-b01c-37c8-00e1-d8e925e79597@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> <6a2f3906-3d7a-6924-7403-8f77d57a18e4@gmx.net> <1685688.1715391218@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Provags-ID: V03:K1:+9i7wh62ycEYG1vbQ+dDxIfO+OQ8DiRoRNkNmm0OZuGmion85Eu 68icFAKyZoXky02xpVPqnPaeP+4wjhjUYSUWUJALUu6Qz4zwZiSably5PVmbhqQwTCAMW+c 7ivO7ivSbpPfs5N+bZyFKWoAiwn7ec0AYdSmj5jLjDd91ArKML7CA4jQc6HpQq6I5ZVyAnt +8mfxmb1tlNi8kPvRJcsw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:n7N4y0F6PG4=;3A6VS+kjkNMg4wlnmNb4033Rh2P G1e1Xn9hE/pRnKQFWatAKqwXuccseRP1NZ3SjJp0M13N88oKfGBjtyEriaBImwEBSFjgD+Mpm 2Ixkvs6waHVi2eRzfl8HISHEa1GnrYTh5hjLz7g57N/2tqr/Sp3wje6InACzrtb2AiAlbDnNQ KPYQ0VN5ZxUzQtlSxnPPOEYaqvVg+l+GVQqL7HWBj1O+KcovszqjC7Zh2zSP9i5+B2L/uaBys lV+NUJtiF6Oyoq/o3uW/q2iEwxrFjCrBReSIy1EKjeESaCIoklI3krYKt9YzI6NGy/madlmuE 0KS9qh9MV5YhrYyDNhWMRqASSfakV+cyEiuZdsDiMbS9zA3BIlhb1cRAWtw6+l40RYITIlEyN DiGgJAk0Nh1/JQ0Wigrio9bUnUCGaRTi57Mm6Ru35z6gPCAtMbstNqbqs6ZPPp22U7eS/Mrrv MKAuG0l63DElfExkgssZyNX0ordGnXRKzQfC50GcehPre+KaILc2/Crwb32JQ+cjPd7L07xNV IEm9Pua0ULpH5qujsuYK6MgCghiyN8siSsN4Hswdg/p83VZ46Y81Vh/YExeVqWP2F0IRdkTV7 YQDmtkKKS0V1dL43w0/JXmuBhd9ToDe9h6otNoU8oYFLqx6wyq6zUNAIvBoFrgHkqfcEy5jAM le6z4BEIsp2qkIR5pHaYAwC109tUzfe9a5pbCcwlMT3rKPhf4pUgw/HRMGlni0VRdDwn6aA/c 1TiTYWkYBi0aIKC4Njt2xVuwuQIRTk/OSyavk4xBqANXHNt+czy9aJ9B0WAe3b9miMQevBsjq 79I9mrrIiM19ukE+7JFMq+GhU+qbNvrK0UU+rOxNT/GSU= Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, 11 May 2024, David Rowley wrote: > On Sat, 11 May 2024 at 13:33, Tom Lane wrote: >> I do kind of wonder why it's producing both a hashagg and a Unique >> step --- seems like it should do one or the other. > > It still needs to make the duplicate groups from parallel workers unique= . Range partitioning of the table guarantees that, since the ranges are not overlapping. Dimitris