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 1syqKk-002Z3H-6E for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Oct 2024 10:23:51 +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 1syqKj-00FZUK-0T for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Oct 2024 10:23:49 +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 1syqKi-00FZSN-OJ for pgsql-bugs@lists.postgresql.org; Thu, 10 Oct 2024 10:23:49 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1syqKg-000BhY-Hv for pgsql-bugs@lists.postgresql.org; Thu, 10 Oct 2024 10:23:47 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-71e02249621so612768b3a.1 for ; Thu, 10 Oct 2024 03:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728555825; x=1729160625; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=QtFw6hAlTF1uuAjFyBFAdSLfzs4MGFedTQ6q8ULH1hQ=; b=fzs2J7eJ/UTTOi/M9wyZxlP4b+AE/ANaEcnkeMqPLy7v6Ytbd6TsKTmHd0LMT5qQWh WhJ/1KlbIESXqgGx0+XwDmbtZx98KQLdkRvvamcGi3sNJxWmzJhPUWai70vtfYM+/fxB ewQAM098y5+4aDsYNQ4va1ebbcp4JV65+KodIS/H/hlyCZ3gy8gBFZ2CCIJsdeA8rZWj IOtoHI3v92VvCypoGj3Ci/ONqOOFyd93SwfeSk1dhs/r06uVpMuQKIK9v8mVulB88PQK 72sSNk1d0+RW2q4BVgcmhZDTu5GScZxk/HGVAXHeYJ/Va+NVEFSTQzU341RVpBPxYVlX VNkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728555825; x=1729160625; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QtFw6hAlTF1uuAjFyBFAdSLfzs4MGFedTQ6q8ULH1hQ=; b=TKmRd3lKLy0bv2qty+NnVy5yFixyZvVsUkKJKtC5KBODYYJ049EziPEafz23qDsBlR u4YDDsywsQ1ee5IlWS0lq6ytqZx6GTxFeBcB7KDvLm3Rv3AF5WHSzenARe0IKs4WZ6lz hXJQ/53tQ4IbbxzrI2aGxTVWBy1vJv3He8ZpaWD/c6DtmKLC9fY8qBC1ILhc3WOdjOef VV1cmE7DNa/F7e9NTYi+z9I+zvQgxYosHWGW9qliCE/CZcDnGm5I4+7E5kXdDjNsySTK 8V6VS1z544TuCfGH8xZvCJISaIgcRjOhbMunaGohznEOeiprNEZkZHAae78K26Cral2l 282w== X-Forwarded-Encrypted: i=1; AJvYcCW3n2STl5CyprsKLDPujzP4xLu1PGpE9xZ9HQg5tuywGBO+L3vTsIIhMbBhRhi4Ya6snmCiCmgterIs@lists.postgresql.org X-Gm-Message-State: AOJu0Yw314hpmPt/01EgN/EUePfGpZGevfntI+7TY5Q76NyKEl9YfGR+ nVzOg+Bm/W2DUhj5L0GirNUee/qzcv2K5ZmqF9e22oItZHbH24P4 X-Google-Smtp-Source: AGHT+IHmqEJUA+bibD8rvV6jSLbF7p07HOmrWOybPD3yKF8lQecy+1j/EHGoX0WFtQ9vyxiLdqgjVQ== X-Received: by 2002:a05:6a00:4616:b0:71d:fe5b:5eb9 with SMTP id d2e1a72fcca58-71e1db75452mr8783797b3a.10.1728555825446; Thu, 10 Oct 2024 03:23:45 -0700 (PDT) Received: from [10.10.20.104] (node-t06.pool-101-109.dynamic.totinternet.net. [101.109.146.214]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71e2a9ea460sm781591b3a.15.2024.10.10.03.23.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Oct 2024 03:23:44 -0700 (PDT) Message-ID: <8026fe90-e661-4448-b9cc-bcbb65629b7b@gmail.com> Date: Thu, 10 Oct 2024 17:23:40 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #18652: Planner can not find pathkey item to sort for query with expression and expression index To: Tender Wang Cc: Richard Guo , exclusion@gmail.com, pgsql-bugs@lists.postgresql.org, Tom Lane References: <18652-deaa782ebcca85d1@postgresql.org> <2527690.1728510183@sss.pgh.pa.us> Content-Language: en-AU From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 10/10/24 16:02, Tender Wang wrote: > > > Andrei Lepikhov > 于2024年 > > I think this is because find_computable_ec_member() only tries to > > match Vars.  Maybe we should teach it to also match OpExprs? > Looking into that case, I don't understand only one thing: > generate_orderedappend_paths decided to try MergeAppend; the > create_append_path routine added the Sort cost,  but the Sort node > itself wasn't added. Maybe the origin problem is the lack of > feasibility > examinations? > > > Yeah, I'm also curious why only cost Sort but not adding Sort node in > create_merge_append_path(). > The comments say that " We'll need to insert a Sort node, so include > cost for that".  Does another place > insert the Sort node? Before inserting the Sort node, we must identify the column corresponding to each path key. And here is the problem: IndexScan has two elements in the target list, but SeqScan has only one. It already looks strange to me. How do we UNION two sources with different numbers of resulting columns? It seems to me we have a bug under the Append node. -- regards, Andrei Lepikhov