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 1lVvcN-0006uI-NT for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Apr 2021 12:24:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lVvcM-0008Fu-Kq for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Apr 2021 12:24:38 +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 1lVvcM-0008Fn-D3 for pgsql-hackers@lists.postgresql.org; Mon, 12 Apr 2021 12:24:38 +0000 Received: from mail-fr2deu01on2077.outbound.protection.outlook.com ([40.107.135.77] helo=DEU01-FR2-obe.outbound.protection.outlook.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lVvcK-0000IS-ID for pgsql-hackers@postgresql.org; Mon, 12 Apr 2021 12:24:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ie/qRJIiKYNjQmqNb9UZfi6TsMqOIVAuYaXyDW9q2ZfL/OwYxfEhZeKu0m+cdj8iA/ckUlEgh24afB7LnJmQ0HhYL6daeRS61CH7aQzLLlaqUl+L9grdyDmkJprPavcYMqgdrOos86I3CvT/nd/+yP8AEYkmX9BPF8u5rO+mTiG+R6WJ0CQwEiH0S9EuoxsJokbhtnPzG3JrpKv3lUSLlwV5rgU06gD/x3tD0Gd2nnb2MOp7p/KKc4sRi6ultIov/V9ScMyl4hRUBI8sEaT4xo4rHBSKJ6p3OxMHOl7uOAtpTXfMOKpLmL3fJJJhcj9JfoitC9yXKgRnMnVNNrrSCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tEXxpANyTRFH8MsLbDaN0e+qYMgDp61FfN7I07YLTfE=; b=NT/6tp8s/ecMBrfTo5w3vRG0sYofYRboQoOG0pfxmJWv9VC1okIETMuZKQnv/P2WOpOOTSI5K+WpghdJbEXK8CjCvIQpq4mrs5kvQhzEQunzA2P5oTOmLxeIMupS1rUlN8NwUb5Lb0lejMF9g7NRN28HlLtuUaHHD19Qibq2FDM3VpwjCYwXv/+SimxrMfxtm7pdevWRR0nVWbUHWRB83S8SGOQaRT6e6as/FELMPo5shf7pV2Mvx3d/kEKeMzc1/bdj7X2t0Q/IjIGUNP38WR/yWmoyXJROncgNyJHaMi4bCVU35LYkl1UQfnp76F9uvECT2XN/dNHyXzGsbFdYnA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=swarm64.com; dmarc=pass action=none header.from=swarm64.com; dkim=pass header.d=swarm64.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swarm64hive.onmicrosoft.de; s=selector1-swarm64hive-onmicrosoft-de; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tEXxpANyTRFH8MsLbDaN0e+qYMgDp61FfN7I07YLTfE=; b=ijFCZIIP27xNhdz2implQGvZshaZ4w49gYsYibGTObIGRXvbxVinLfWzXQ1L/6sO/P6lGVxhpNX7fH2dLiEGmE8PR0IOk0t8CpKdFLTDMyc/ITgRTuQxi6bR6gnyeWpF+JMx/ECzy0/9FhkoGksaLg4p4166h2zMa1gnTsJ9vVA= Authentication-Results: postgresql.org; dkim=none (message not signed) header.d=none;postgresql.org; dmarc=none action=none header.from=swarm64.com; Received: from FRYP281MB0581.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:44::10) by FR2P281MB0026.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.10; Mon, 12 Apr 2021 12:24:34 +0000 Received: from FRYP281MB0581.DEUP281.PROD.OUTLOOK.COM ([fe80::cc8d:1f4d:2393:e7b0]) by FRYP281MB0581.DEUP281.PROD.OUTLOOK.COM ([fe80::cc8d:1f4d:2393:e7b0%7]) with mapi id 15.20.4042.014; Mon, 12 Apr 2021 12:24:34 +0000 To: PostgreSQL-development From: Luc Vlaming Subject: "could not find pathkey item to sort" for TPC-DS queries 94-96 Message-ID: <91f3ec99-85a4-fa55-ea74-33f85a5c651f@swarm64.com> Date: Mon, 12 Apr 2021 14:24:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [2a02:8109:a0c0:2c:56ee:75ff:fe80:b7f2] X-ClientProxiedBy: AM0PR04CA0043.eurprd04.prod.outlook.com (2603:10a6:208:1::20) To FRYP281MB0581.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:44::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [IPv6:2a02:8109:a0c0:2c:56ee:75ff:fe80:b7f2] (2a02:8109:a0c0:2c:56ee:75ff:fe80:b7f2) by AM0PR04CA0043.eurprd04.prod.outlook.com (2603:10a6:208:1::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Mon, 12 Apr 2021 12:24:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 301da2b0-88ea-4796-fba2-08d8fdadee17 X-MS-TrafficTypeDiagnostic: FR2P281MB0026: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9TqvGZDJtAXEulN3VKEvBjf0EMFjlHORMTE2w4KyZgHZD1ipmT+5YHY6ecmB8gavkLDqH8+1JzB88hx30ExKPuFDGZUVtYWixM0AT2N++ezNe/XkL1meV6e1UzCMmyjhFmmwpyheZpZ7KLG+YzvCd2i+VCeFRYHXHv76MBGHuh45ztY/8L9TfCExj/Vb8LDANhs/h4XPwyvrjOb80FdsalNH3JnsIC87iRnx5CFuFAGJfEFd1QHVBQTdZHOyUZirIjGMXA5k1lBJ32BFwiKL+E5BR7IEz/ybBWKh07LfWQ04E/XfbA8Un0BFP5uN34RjsmWDu5iEfXLighqDQrJQ5pdDyuf9yYvrPawONEJw/aBYASGtknjd0jLUxTA3Mn2+HQ2T+iDibaJkbi4uk/EGpAY8p1UpioaM1OfVl/RgUUvE1zbnKPZcu96w1fq8TUDxi5v+yp2wtAZeTyvsD5n6U2V/MuxoBQSOcB++4DGndL1zebg+6YO9h9SvrwBUJDEcI2EECR54rkLXwcvOslYxjGjgnIjDm9UnEKBDCgtKNk6DPZSvVZUGbsBdCq8vTae4XqORBosxK8vnxRfZOO/v4sOV+naiFY46f0QAq0aYhopyJq+aWHmNXmyJS7o1N+CKPFrQDeCLtE5bjlHQfuIEg2yv6joMjB3+qeeSbKvv4Wd65tdnlwjvuYE1nj7JoaTbssdG/Ld3XxcEqt3eDAawHdhMnKbZn8xJbfTuLXmUnmkjlhg7RHewHDu9ZBdFg3If4wCVN2/k16skqvoKCEON2A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:FRYP281MB0581.DEUP281.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(396003)(346002)(376002)(39830400003)(136003)(366004)(5660300002)(6916009)(31686004)(6486002)(186003)(966005)(16526019)(52116002)(86362001)(66946007)(31696002)(66556008)(8936002)(66476007)(316002)(36756003)(38100700002)(83380400001)(2906002)(2616005)(8676002)(478600001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?R0ZKd1ZlZGd6bEI1WVA3TEtlMTJmODJ3aVN1MzJ0bWM0WllhcW5DZzg4alNw?= =?utf-8?B?cGI0L2ltWkp3NzJBUWxndlZpY1NJVUtPdjNSRjBwMG90RDIvMU9DMC9Ic2E0?= =?utf-8?B?L2w2akJSMGhmRzNiZmVSYTl0MDIwRlQ3Y3RuQVgzNGsrb3pGRE54cGNwSVNy?= =?utf-8?B?Wlk4dVF3eTZrdG5MaHIvakxwdEI0aEpieDk5SjB5bEdnczBKWU1VWXJxNzJJ?= =?utf-8?B?VXNTT1ZLdmw2ZEFVdlBSRlV4Qjk3c2xYbHdTc0oza3BFbW9qeko5d2RVQmhG?= =?utf-8?B?Mkk1K1J0VE0zcTNUandMZGN4U2hTNDhiczdPZTM5TEdvTXRMQUNDNk8xT1My?= =?utf-8?B?RXRuN3QrUzljamJNRDdLMmVzSXZxRDNicDdMU25oVVU2ak5lQWZFa2tnZUQ2?= =?utf-8?B?WFd4ajlLT3JUMHVnUVQ1R0FiVk52cGVjU1YxQmEvWGgvOUR4UmE3bzhCaXlN?= =?utf-8?B?ZS81dVZ0MGh1VU1QZEZzZXRVa0ZXVGZVM3QzL3g5MThaT0l1Zk8zWDdJamtQ?= =?utf-8?B?U2NuYjJpSmdFNVhQOUpYZmZWdUx0ZDZ4Ymt6QTNIeG85ZXo3bDNnSExwTWZo?= =?utf-8?B?dmxtT2VuSlVadGM2d2tNL05zU2dXYThNRFFNVURQbmZuS1VTSkhhT0k3SjNS?= =?utf-8?B?MFBPMUU5a20rZ1hCMDlzUSt4cWFIU29EL0tIcjE1UStIelBFMTgwV21VMGg5?= =?utf-8?B?TzhXM0VUUlBkREhaOHVmNXFIaFpiMHo0T3FhWmlLZEhDYVkyb2hVRjFOT2NZ?= =?utf-8?B?OXMxTXR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?= =?utf-8?B?NzlINCtJNVoyZGRPeU5QZ2FOVEw3VVVBY0JsTG1XS1JrNXltY0NTU0RIZmtL?= =?utf-8?B?V1FBRzBlVzhwRlE3RHJlWE5kUUVER0Iyck1GcnFrNGVjaHlaZHRkNFlqNEU0?= =?utf-8?B?SDAzU0xDZXdGakpmMlpaUWJGeEREdm5NVkZrZkVpUDZqR2IwU3FnYVJwd1dp?= =?utf-8?Q?1Ovy2akkBzaTY?= X-OriginatorOrg: swarm64.com X-MS-Exchange-CrossTenant-Network-Message-Id: 301da2b0-88ea-4796-fba2-08d8fdadee17 X-MS-Exchange-CrossTenant-AuthSource: FRYP281MB0581.DEUP281.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2021 12:24:33.9350 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 6a3a733d-0e05-4774-8f9e-4fc6a12face6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6tJZ0BAYSZfv3aZNkl5qWr7NUyItt4+tcsOIXxR8m9L3XDaHkkX1ZdQRS7BMsteD X-MS-Exchange-Transport-CrossTenantHeadersStamped: FR2P281MB0026 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, When trying to run on master (but afaik also PG-13) TPC-DS queries 94, 95 and 96 on a SF10 I get the error "could not find pathkey item to sort". When I disable enable_gathermerge the problem goes away and then the plan for query 94 looks like below. I tried figuring out what the problem is but to be honest I would need some pointers as the code that tries to matching equivalence members in prepare_sort_from_pathkeys is something i'm really not familiar with. To reproduce you can either ingest and test using the toolkit I used too (see https://github.com/swarm64/s64da-benchmark-toolkit/), or alternatively just use the schema (see https://github.com/swarm64/s64da-benchmark-toolkit/tree/master/benchmarks/tpcds/schemas/psql_native) Best, Luc ------------------------------------------------------------------------------------------------------------------------------------------------ Limit (cost=229655.62..229655.63 rows=1 width=72) -> Sort (cost=229655.62..229655.63 rows=1 width=72) Sort Key: (count(DISTINCT ws1.ws_order_number)) -> Aggregate (cost=229655.60..229655.61 rows=1 width=72) -> Nested Loop Semi Join (cost=1012.65..229655.59 rows=1 width=16) -> Nested Loop (cost=1012.22..229653.73 rows=1 width=20) Join Filter: (ws1.ws_web_site_sk = web_site.web_site_sk) -> Nested Loop (cost=1012.22..229651.08 rows=1 width=24) -> Gather (cost=1011.80..229650.64 rows=1 width=28) Workers Planned: 2 -> Nested Loop Anti Join (cost=11.80..228650.54 rows=1 width=28) -> Hash Join (cost=11.37..227438.35 rows=2629 width=28) Hash Cond: (ws1.ws_ship_date_sk = date_dim.d_date_sk) -> Parallel Seq Scan on web_sales ws1 (cost=0.00..219548.92 rows=3000992 width=32) -> Hash (cost=10.57..10.57 rows=64 width=4) -> Index Scan using idx_d_date on date_dim (cost=0.29..10.57 rows=64 width=4) Index Cond: ((d_date >= '2000-03-01'::date) AND (d_date <= '2000-04-30'::date)) -> Index Only Scan using idx_wr_order_number on web_returns wr1 (cost=0.42..0.46 rows=2 width=4) Index Cond: (wr_order_number = ws1.ws_order_number) -> Index Scan using customer_address_pkey on customer_address (cost=0.42..0.44 rows=1 width=4) Index Cond: (ca_address_sk = ws1.ws_ship_addr_sk) Filter: ((ca_state)::text = 'GA'::text) -> Seq Scan on web_site (cost=0.00..2.52 rows=10 width=4) Filter: ((web_company_name)::text = 'pri'::text) -> Index Scan using idx_ws_order_number on web_sales ws2 (cost=0.43..1.84 rows=59 width=8) Index Cond: (ws_order_number = ws1.ws_order_number) Filter: (ws1.ws_warehouse_sk <> ws_warehouse_sk) The top of the stacktrace is: #0 errfinish (filename=0x5562dc1a5125 "createplan.c", lineno=6186, funcname=0x5562dc1a54d0 <__func__.14> "prepare_sort_from_pathkeys") at elog.c:514 #1 0x00005562dbc2d7de in prepare_sort_from_pathkeys (lefttree=0x5562dc5a2f58, pathkeys=0x5562dc4eabc8, relids=0x0, reqColIdx=0x0, adjust_tlist_in_place=, p_numsortkeys=0x7ffc0b8cda84, p_sortColIdx=0x7ffc0b8cda88, p_sortOperators=0x7ffc0b8cda90, p_collations=0x7ffc0b8cda98, p_nullsFirst=0x7ffc0b8cdaa0) at createplan.c:6186 #2 0x00005562dbe8d695 in make_sort_from_pathkeys (lefttree=, pathkeys=, relids=) at createplan.c:6313 #3 0x00005562dbe8eba3 in create_sort_plan (flags=1, best_path=0x5562dc548d68, root=0x5562dc508cf8) at createplan.c:2118 #4 create_plan_recurse (root=0x5562dc508cf8, best_path=0x5562dc548d68, flags=1) at createplan.c:489 #5 0x00005562dbe8f315 in create_gather_merge_plan (best_path=0x5562dc5782f8, root=0x5562dc508cf8) at createplan.c:1885 #6 create_plan_recurse (root=0x5562dc508cf8, best_path=0x5562dc5782f8, flags=) at createplan.c:541 #7 0x00005562dbe8ddad in create_nestloop_plan (best_path=0x5562dc585668, root=0x5562dc508cf8) at createplan.c:4237 #8 create_join_plan (best_path=0x5562dc585668, root=0x5562dc508cf8) at createplan.c:1062 #9 create_plan_recurse (root=0x5562dc508cf8, best_path=0x5562dc585668, flags=) at createplan.c:418 #10 0x00005562dbe8ddad in create_nestloop_plan (best_path=0x5562dc5c4428, root=0x5562dc508cf8) at createplan.c:4237 #11 create_join_plan (best_path=0x5562dc5c4428, root=0x5562dc508cf8) at createplan.c:1062 #12 create_plan_recurse (root=0x5562dc508cf8, best_path=0x5562dc5c4428, flags=) at createplan.c:418 #13 0x00005562dbe8ddad in create_nestloop_plan (best_path=0x5562dc5d3bd8, root=0x5562dc508cf8) at createplan.c:4237 #14 create_join_plan (best_path=0x5562dc5d3bd8, root=0x5562dc508cf8) at createplan.c:1062 #15 create_plan_recurse (root=0x5562dc508cf8, best_path=0x5562dc5d3bd8, flags=) at createplan.c:418 #16 0x00005562dbe8e428 in create_agg_plan (best_path=0x5562dc5d6f08, root=0x5562dc508cf8) at createplan.c:2238 #17 create_plan_recurse (root=0x5562dc508cf8, best_path=0x5562dc5d6f08, flags=3) at createplan.c:509 #18 0x00005562dbe8eb73 in create_sort_plan (flags=1, best_path=0x5562dc5d7378, root=0x5562dc508cf8) at createplan.c:2109 #19 create_plan_recurse (root=0x5562dc508cf8, best_path=0x5562dc5d7378, flags=1) at createplan.c:489 #20 0x00005562dbe8e7e8 in create_limit_plan (flags=1, best_path=0x5562dc5d7a08, root=0x5562dc508cf8) at createplan.c:2784 #21 create_plan_recurse (root=0x5562dc508cf8, best_path=0x5562dc5d7a08, flags=1) at createplan.c:536 #22 0x00005562dbe914ae in create_plan (root=root@entry=0x5562dc508cf8, best_path=) at createplan.c:349