Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n9iRL-0003G5-Vw for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Jan 2022 06:57:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n9iRK-00076i-Qz for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Jan 2022 06:57:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n9iRK-00076Z-Hs for pgsql-hackers@lists.postgresql.org; Tue, 18 Jan 2022 06:57:58 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n9iRI-0003PT-0E for pgsql-hackers@postgresql.org; Tue, 18 Jan 2022 06:57:58 +0000 Received: by mail-pj1-x1030.google.com with SMTP id n16-20020a17090a091000b001b46196d572so1917945pjn.5 for ; Mon, 17 Jan 2022 22:57:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=maI7Z3A2XJbP88JbaA1MMOctbz8L3EbJy6ymNkBT8Fs=; b=VJy6CADeo+fv2FLbNVWDEmiJO0LbVERiOSfWrQzZKhsW/NnKtoabgqyuVtgrTNnSmN NHIPm9gtVKCEisWRIXpBJFRwvllyBp8aVbdDmQ735gBMhvGbG7s5dWvDqCQ103if88gT AyIuswbPH7m1C2rS286qqO/nNRlky9K/oBUV+O5hPtBQyCq0/4b/8Aw3LvhjQsS+cjUq gvn0MPg+RrCrf5TezA0WT+GtaHgjE0XH4xlyX1GgfVBF4fv2oDnMwRYULrr410hPozDf QBJIynUU+EX6q1q16JDMdTH+thqyQVvmckvw53Lb22+FyyOA3KnQMpQxTGWl8Rev1AWX P4RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=maI7Z3A2XJbP88JbaA1MMOctbz8L3EbJy6ymNkBT8Fs=; b=MZcr2O5yrrKZwJnbMypMishs3LtyfjN/fKSJjho0O2HYy2w94/S/nECdCboCKUqgGi kZ1psJpfSVznkQ9czTuoSEIXcR1KtIRRLx1BDFHUeKMwP9N2pTfIpkxdRJAFpDtjP0Vk dJh/GSqmX3KB03HoDoh1Deo7u2XOS5r+n7J5YcRYTU9xPnhOKVCZURNnza4ASmLEpyQu nruvMbAiIhwko3OckpaSvNR9tWTTzEIpRwLrkhd5m3JVPkjDeBXQdtYdY4phjDgQ8qxC o0kQtr4+eYRXtodVsasX3fBe8uG+XmKbHJqT8f/Yh9owTHuujo3ScJfm3J8HlaNXk+mk k1qQ== X-Gm-Message-State: AOAM531zmIKycChf0cR5jJLxl/dMGQKqCt/QnFCXQpdODKzKwoZ+l3Zb /OwwvHSDIITt4/3JrfzSj8M= X-Google-Smtp-Source: ABdhPJy6C9gWxpaLG1ecPixSBXK6pq7+w83NLAK2oq6jgF01elht263UUe3QkueofGaSOAxM67n+/A== X-Received: by 2002:a17:90a:348c:: with SMTP id p12mr38216551pjb.90.1642489073956; Mon, 17 Jan 2022 22:57:53 -0800 (PST) Received: from jrouhaud (1-171-184-213.dynamic-ip.hinet.net. [1.171.184.213]) by smtp.gmail.com with ESMTPSA id x26sm17100940pfh.192.2022.01.17.22.57.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jan 2022 22:57:53 -0800 (PST) Date: Tue, 18 Jan 2022 14:57:50 +0800 From: Julien Rouhaud To: Arne Roland Cc: Alvaro Herrera , pgsql-hackers Subject: Re: missing indexes in indexlist with partitioned tables Message-ID: <20220118065750.v5zigpuisljc6jmk@jrouhaud> References: <405b11a5a0504b76b997e312e543a69b@index.de> <202201171816.r6tkrn7drkm3@alvherre.pgsql> <2641568c18de40e8b1528fc9d4d80127@index.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2641568c18de40e8b1528fc9d4d80127@index.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Mon, Jan 17, 2022 at 08:32:40PM +0000, Arne Roland wrote: > > Afaiac the join pruning where the outer table is a partitioned table is the relevant case. The last version of the patch now fails on all platform, with plan changes. For instance: https://cirrus-ci.com/task/4825629131538432 https://api.cirrus-ci.com/v1/artifact/task/4825629131538432/regress_diffs/src/test/regress/regression.diffs diff -U3 /tmp/cirrus-ci-build/src/test/regress/expected/partition_join.out /tmp/cirrus-ci-build/src/test/regress/results/partition_join.out --- /tmp/cirrus-ci-build/src/test/regress/expected/partition_join.out 2022-01-17 23:08:47.158198249 +0000 +++ /tmp/cirrus-ci-build/src/test/regress/results/partition_join.out 2022-01-17 23:12:34.163488567 +0000 @@ -4887,37 +4887,23 @@ SET enable_partitionwise_join = on; EXPLAIN (COSTS OFF) SELECT * FROM fract_t x LEFT JOIN fract_t y USING (id) ORDER BY id ASC LIMIT 10; - QUERY PLAN ------------------------------------------------------------------------ + QUERY PLAN +----------------------------------------------------------------- Limit - -> Merge Append - Sort Key: x.id - -> Merge Left Join - Merge Cond: (x_1.id = y_1.id) - -> Index Only Scan using fract_t0_pkey on fract_t0 x_1 - -> Index Only Scan using fract_t0_pkey on fract_t0 y_1 - -> Merge Left Join - Merge Cond: (x_2.id = y_2.id) - -> Index Only Scan using fract_t1_pkey on fract_t1 x_2 - -> Index Only Scan using fract_t1_pkey on fract_t1 y_2 -(11 rows) + -> Append + -> Index Only Scan using fract_t0_pkey on fract_t0 x_1 + -> Index Only Scan using fract_t1_pkey on fract_t1 x_2 +(4 rows) EXPLAIN (COSTS OFF) SELECT * FROM fract_t x LEFT JOIN fract_t y USING (id) ORDER BY id DESC LIMIT 10; - QUERY PLAN --------------------------------------------------------------------------------- + QUERY PLAN +-------------------------------------------------------------------------- Limit - -> Merge Append - Sort Key: x.id DESC - -> Nested Loop Left Join - -> Index Only Scan Backward using fract_t0_pkey on fract_t0 x_1 - -> Index Only Scan using fract_t0_pkey on fract_t0 y_1 - Index Cond: (id = x_1.id) - -> Nested Loop Left Join - -> Index Only Scan Backward using fract_t1_pkey on fract_t1 x_2 - -> Index Only Scan using fract_t1_pkey on fract_t1 y_2 - Index Cond: (id = x_2.id) -(11 rows) + -> Append + -> Index Only Scan Backward using fract_t1_pkey on fract_t1 x_2 + -> Index Only Scan Backward using fract_t0_pkey on fract_t0 x_1 +(4 rows)