Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIw2b-0006oF-Cr for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Oct 2019 14:37:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iIw2a-00031N-7J for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Oct 2019 14:37:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIw2Z-00030S-Mh for pgsql-hackers@lists.postgresql.org; Fri, 11 Oct 2019 14:37:11 +0000 Received: from mail-io1-xd2d.google.com ([2607:f8b0:4864:20::d2d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iIw2W-0004ro-HU for pgsql-hackers@lists.postgresql.org; Fri, 11 Oct 2019 14:37:10 +0000 Received: by mail-io1-xd2d.google.com with SMTP id z19so22074654ior.0 for ; Fri, 11 Oct 2019 07:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=QYy+TRUmYnrVHc0RyYUpkwsowRaB46nwWZW/fcAVozw=; b=Iz+oXE+nUd4PMf52rGX7CLKY5AjUtzLflHU7M5/s2PnZejQQv1CTF8c/UtIz+FGiTP eGRm7hm94brIukCvDmfFA9ucuKfMAGh5W3oE72yJZ7GH4bHNh6N31+JbWrsYlfba6xNu WwGWjRtgsN9Hseob16ubEvVwk+LEclYG+mY2UzEnN4Chbvk8YmsqeHS6oMFOatgVb83E jBTA5iu2SMNOlnaq0ekH2iiEcfdrLdfEba/gScKpsjVbbchsSBW23oUHsf3eVIRXdnbL izvROmneVjwdYpiyShob8ptVmHcZfLY5V4Rehah9YNEN1bbWaOBA/ZmB6/bXuiGigO3R N41A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=QYy+TRUmYnrVHc0RyYUpkwsowRaB46nwWZW/fcAVozw=; b=UfxtGvleDaMAipZBoLQiVtMONm2z3hTUum9VgUbmUChCxs0A42OHJNnWZFghO/xcSx YAd1BX5KQI89H5SF4+ztA1mwrdezbA2ikC6DdH4PZGl10/VwtJKfanAcnm+PMvx7CpYd wSdEaQjs92W1J+dptC4PKZ4i6wKeRrhfCou/8MeQ4ZL4mINwLyz4ned5qozsJ3N0mTEr grADwikXMQE6GO06Jg2Wiq7KQWFMpsp4p93CcbkESbyVYahx2hq1qp+0JBxzNfrUn7QS kjZUvezU8+6MUhkYg5klsr70ETrhMOcUmFQHl2a04LWCLUfZH9lxttrE1kQClBde40K+ HzwQ== X-Gm-Message-State: APjAAAUQOdZqUNsOC+1hrEk0dn2bJ/5h3rGJ/sA/TFy4AqyZYb9mDRLI czkR6Wuvv0JBhYisRLsMawKddPxcRuw= X-Google-Smtp-Source: APXvYqxgF80iaXFHM9Y7jXPuhQPNYlaocpCGNe8DEPl+51eu+tJlz+ouLeLoLKQDGUemTo1IS5Qn+g== X-Received: by 2002:a02:cabb:: with SMTP id e27mr17882320jap.113.1570804627138; Fri, 11 Oct 2019 07:37:07 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id f12sm5873039iob.58.2019.10.11.07.37.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Oct 2019 07:37:06 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 07E92801D2A; Fri, 11 Oct 2019 09:37:03 -0500 (CDT) Date: Fri, 11 Oct 2019 09:37:03 -0500 From: Justin Pryzby To: pgsql-hackers@lists.postgresql.org Subject: v12.0: ERROR: could not find pathkey item to sort Message-ID: <20191011143703.GN10470@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I've reduced the failing query as much as possible to this: -- This is necessary to fail: SET enable_nestloop=off; SELECT * FROM (SELECT start_time, t1.site_id FROM pgw_kpi_view t1 -- Apparently the where clause is necessary to fail... WHERE (start_time>='2019-10-10' AND start_time<'2019-10-11') -- The group by MAY be necessary to fail... GROUP BY 1,2 ) AS data JOIN sites ON ( sites.site_location='' OR sites.site_office=data.site_id) The view is actually a join of two relkind=p partitioned tables (which I will acknowledge probably performs poorly). (gdb) bt #0 errfinish (dummy=dummy@entry=0) at elog.c:411 #1 0x000000000087a959 in elog_finish (elevel=elevel@entry=20, fmt=fmt@entry=0x9d93d8 "could not find pathkey item to sort") at elog.c:1365 #2 0x00000000006a587f in prepare_sort_from_pathkeys (lefttree=0x7f7cb84492e8, pathkeys=, relids=0x7f7cb8410700, reqColIdx=reqColIdx@entry=0x0, adjust_tlist_in_place=, adjust_tlist_in_place@entry=false, p_numsortkeys=p_numsortkeys@entry=0x7ffc4b2e10c4, p_sortColIdx=p_sortColIdx@entry=0x7ffc4b2e10c8, p_sortOperators=p_sortOperators@entry=0x7ffc4b2e10d0, p_collations=p_collations@entry=0x7ffc4b2e10d8, p_nullsFirst=p_nullsFirst@entry=0x7ffc4b2e10e0) at createplan.c:5893 #3 0x00000000006a5a6a in make_sort_from_pathkeys (lefttree=, pathkeys=, relids=) at createplan.c:6020 #4 0x00000000006a6e30 in create_sort_plan (flags=4, best_path=0x7f7cb8410cc8, root=0x7f7fdc3ac6b0) at createplan.c:1985 #5 create_plan_recurse (root=root@entry=0x7f7fdc3ac6b0, best_path=0x7f7cb8410cc8, flags=flags@entry=4) at createplan.c:459 #6 0x00000000006a6e4e in create_group_plan (best_path=0x7f7cb8410d58, root=0x7f7fdc3ac6b0) at createplan.c:2012 #7 create_plan_recurse (root=root@entry=0x7f7fdc3ac6b0, best_path=best_path@entry=0x7f7cb8410d58, flags=flags@entry=1) at createplan.c:464 #8 0x00000000006a8278 in create_merge_append_plan (flags=4, best_path=0x7f7cb8446cd8, root=0x7f7fdc3ac6b0) at createplan.c:1333 #9 create_plan_recurse (root=root@entry=0x7f7fdc3ac6b0, best_path=0x7f7cb8446cd8, flags=flags@entry=4) at createplan.c:402 #10 0x00000000006a6e4e in create_group_plan (best_path=0x7f7cb84486c8, root=0x7f7fdc3ac6b0) at createplan.c:2012 #11 create_plan_recurse (root=root@entry=0x7f7fdc3ac6b0, best_path=0x7f7cb84486c8, flags=flags@entry=1) at createplan.c:464 #12 0x00000000006a9739 in create_plan (root=0x7f7fdc3ac6b0, best_path=) at createplan.c:325 #13 0x00000000006aa988 in create_subqueryscan_plan (scan_clauses=0x0, tlist=0x7f7cb8450820, best_path=0x7f7cb8448db8, root=0x7f7fdc34b948) at createplan.c:3385 #14 create_scan_plan (root=root@entry=0x7f7fdc34b948, best_path=best_path@entry=0x7f7cb8448db8, flags=, flags@entry=0) at createplan.c:670 #15 0x00000000006a6d31 in create_plan_recurse (root=root@entry=0x7f7fdc34b948, best_path=0x7f7cb8448db8, flags=flags@entry=0) at createplan.c:427 #16 0x00000000006a983a in create_nestloop_plan (best_path=0x7f7cb844fb80, root=0x7f7fdc34b948) at createplan.c:4008 #17 create_join_plan (root=root@entry=0x7f7fdc34b948, best_path=best_path@entry=0x7f7cb844fb80) at createplan.c:1020 #18 0x00000000006a6d75 in create_plan_recurse (root=root@entry=0x7f7fdc34b948, best_path=0x7f7cb844fb80, flags=flags@entry=1) at createplan.c:393 #19 0x00000000006a9739 in create_plan (root=root@entry=0x7f7fdc34b948, best_path=) at createplan.c:325 #20 0x00000000006b5a04 in standard_planner (parse=0x1bd2308, cursorOptions=256, boundParams=0x0) at planner.c:413 #21 0x000000000075fb2e in pg_plan_query (querytree=querytree@entry=0x1bd2308, cursorOptions=cursorOptions@entry=256, boundParams=boundParams@entry=0x0) at postgres.c:878 #22 0x000000000075fbee in pg_plan_queries (querytrees=, cursorOptions=cursorOptions@entry=256, boundParams=boundParams@entry=0x0) at postgres.c:968 #23 0x000000000076007a in exec_simple_query ( query_string=0x1ba36e0 "SELECT * FROM\n\t(SELECT start_time, t1.site_id\n\tFROM pgw_kpi_view t1\n\t\n\tWHERE (start_time>='2019-10-10' AND start_time<'2019-10-11')\n\t\n\tGROUP BY 1,2\n\t) AS data\nJOIN sites ON ( sites.site_location='' OR"...) at postgres.c:1143 #24 0x0000000000761212 in PostgresMain (argc=, argv=argv@entry=0x1bd8e70, dbname=0x1bd8d10 "ts", username=) at postgres.c:4236 #25 0x0000000000483d02 in BackendRun (port=, port=) at postmaster.c:4431 #26 BackendStartup (port=0x1bd5190) at postmaster.c:4122 #27 ServerLoop () at postmaster.c:1704 #28 0x00000000006f0b1f in PostmasterMain (argc=argc@entry=3, argv=argv@entry=0x1b9e280) at postmaster.c:1377 #29 0x0000000000484c93 in main (argc=3, argv=0x1b9e280) at main.c:228 bt f: #2 0x00000000006a587f in prepare_sort_from_pathkeys (lefttree=0x7f7cb84492e8, pathkeys=, relids=0x7f7cb8410700, reqColIdx=reqColIdx@entry=0x0, adjust_tlist_in_place=, adjust_tlist_in_place@entry=false, p_numsortkeys=p_numsortkeys@entry=0x7ffc4b2e10c4, p_sortColIdx=p_sortColIdx@entry=0x7ffc4b2e10c8, p_sortOperators=p_sortOperators@entry=0x7ffc4b2e10d0, p_collations=p_collations@entry=0x7ffc4b2e10d8, p_nullsFirst=p_nullsFirst@entry=0x7ffc4b2e10e0) at createplan.c:5893 sortexpr = ec = 0x7f7cb8edbe28 em = tle = pathkey = pk_datatype = sortop = j = tlist = 0x7f7cb8451bb8 i = 0x7f7cb8edc2d8 numsortkeys = 0 sortColIdx = 0x7f7cb8451c58 sortOperators = 0x7f7cb8451c70 collations = 0x7f7cb8451c88 nullsFirst = 0x7f7cb8451ca0 __func__ = "prepare_sort_from_pathkeys" #3 0x00000000006a5a6a in make_sort_from_pathkeys (lefttree=, pathkeys=, relids=) at createplan.c:6020 numsortkeys = 32636 sortColIdx = 0x7f7cb8447468 sortOperators = 0x7f7cb83fa278 collations = 0x0 nullsFirst = 0x7f7cb8edc2f8