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 1s6WZL-0006uu-3X for pgsql-general@arkaria.postgresql.org; Mon, 13 May 2024 14:22:24 +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 1s6WZL-000j9h-1V for pgsql-general@arkaria.postgresql.org; Mon, 13 May 2024 14:22:23 +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 1s6WZK-000j9Y-Mo for pgsql-general@lists.postgresql.org; Mon, 13 May 2024 14:22:22 +0000 Received: from mail-lj1-x22d.google.com ([2a00:1450:4864:20::22d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s6WZH-0000fu-OS for pgsql-general@lists.postgresql.org; Mon, 13 May 2024 14:22:21 +0000 Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2e09138a2b1so62078331fa.3 for ; Mon, 13 May 2024 07:22:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715610138; x=1716214938; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=5KaTCRoaeSbJHnCfvKyUXaXg2ly7pPqCVySQ0oy7io4=; b=dn69p0MAxh6SilNeN3xRXQxq4LOxhGrAL/igXvAy/JG8N1VPIvpCP7O3WZE81jxqy7 XwKMagP2MOibn1kkFZUlupfeyNuBu/pbif8E/jLTzTZrVzc7pyB2rf+BlxJf4Hp95uDx IFT9jQ1zRB4trXedKt6Hoxdf9k4f12Nh2J3d3pFXzd+PqkkFNHvSMzy2zm7jtOrePVWH ALOQIsXh5OjrhEGkFOCwTrX2vZMu6/icnU3xQlXF4TsBoUfbD5LUvqpEPfaFdvw3gXmp ZuO3GPL9DXjEKGwsBq/d4wEKSpN1AqjqRxPVBZ8umtu3L//acealJ0F+70TYr9RXhRUM kp0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715610138; x=1716214938; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5KaTCRoaeSbJHnCfvKyUXaXg2ly7pPqCVySQ0oy7io4=; b=sUCrXBvgAg5M2BJhxh0v994IJBOH1ldU0JymcwcX6VWSmfHMB3VDf7nd5PGjLRULPe U3RVHaPjvKGgpp3qPbhYVP7gxIa1+fVhXrmrmsFW7U02KDUtbdz3Hn7pLPXe2SFCuany 6yjlf1c39Rwx9nbHlO/7KdQuln1//PPCh1hjPdtpIdjY2GcYrvs0YmIrFNbI9bwliF3F aG92R+T9mBBDyncem25NBtWsCNdPYXRfiOu75SKO0z44121aW851QELkI7z2+N2+S8xq PCUXCqalztuMVCHMR64l0fGlWXuSXC2SEc2hB0rxoCUhe0uS574pVVXRDGJzG4c5d6WZ 2tXQ== X-Forwarded-Encrypted: i=1; AJvYcCW0XTYfRIEae9dOFfYiRP+uncZMML3i7fNMby7sukfADRDYjWVtDgkrIm5tTXsayB+dIEg7WzXfBrnVeqYPj4iv8Fvth0JSKMsCQMtd3z70L0bX X-Gm-Message-State: AOJu0YwT48uD8HeBMZa80dsL9FTtuTfxx4jDh7tuw/dCTHpZba1xTVAq kwzpse+A/TP5Nu8iErTbj+WDRE/jJsD36puPRit6llMZ0Kd0CplrXSVShPh+PGccqjfHQcsAYN0 ronpVrM7FL1AAKhgX+ClyLkm7qI8= X-Google-Smtp-Source: AGHT+IH3XA7b+aOFvqhNA8ZKQ5e1HWQhIWpATNq7yxwjq5UaWwOSP4WnymrqNUssIO2eWiSSxi3K6Y6PS740BtlwcCQ= X-Received: by 2002:a2e:7306:0:b0:2d8:b2e:7bf3 with SMTP id 38308e7fff4ca-2e51f263691mr61229341fa.0.1715610137835; Mon, 13 May 2024 07:22:17 -0700 (PDT) MIME-Version: 1.0 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> <2e3947bd-b01c-37c8-00e1-d8e925e79597@gmx.net> <410018fd-1f9b-41b7-6257-89844b984564@gmx.net> In-Reply-To: <410018fd-1f9b-41b7-6257-89844b984564@gmx.net> From: David Rowley Date: Tue, 14 May 2024 02:22:03 +1200 Message-ID: Subject: Re: SELECT DISTINCT chooses parallel seqscan instead of indexscan on huge table with 1000 partitions To: Dimitrios Apostolou Cc: Tom Lane , pgsql-general@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 14 May 2024 at 02:07, Dimitrios Apostolou wrote: > > On Tue, 14 May 2024, David Rowley wrote: > > Parallel Append can also run in a way that the Append child nodes will > > only get 1 worker each. > > How can I tell which case it is, from the EXPLAIN output (for example > the output at [1]) ? IIRC, the planner does prefer to use Parallel aware child Paths when creating a Parallel Append. Given equivalent costs, there's no advantage to it choosing a non-parallel aware Path. The planner does not have any optimisations that that would enable. However, it is possible that the planner *could* generate these. All the Append subpaths would just have to all be parallel safe but not parallel aware. You could identify them in EXPLAIN by seeing a "Parallel Append" without the "Parallel" in front of the node names in any of the Parallel Append's subpaths. David