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 1sTEtO-00EJHI-FY for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Jul 2024 06:08:58 +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 1sTEtN-008ZiI-5J for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Jul 2024 06:08:57 +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 1sTEtM-008Zi9-RN for pgsql-hackers@lists.postgresql.org; Mon, 15 Jul 2024 06:08:56 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sTEtK-0027XG-BG for pgsql-hackers@lists.postgresql.org; Mon, 15 Jul 2024 06:08:55 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-52eafec1e84so5234461e87.0 for ; Sun, 14 Jul 2024 23:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721023732; x=1721628532; 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=dm/k7gFIMhdyfC4SGzvRbrKukaD9JWCFWZBHyaB3OaE=; b=crNmKlkjlbBNKC/+ppYulNIuO8Hzhwi7MRdn5Ye6TqEAZYNK7LRMQMaObmrSW3TX2F dwhB55GMyAM5lNez5QxUMJb1ijWTcsS+EWfw+AOd5yz/F1yUBaJ45LOgXx3qd2oTpb80 EA25424Mi2Ho0FuxfyCQibKy+wCnN7KMUFqww82WIp+OgJOZzWInnJBlJRtUXkGMHLQh P26mbpygMfuP66I8CmAcGcXnWYAs7pb3f7bI98S0wloGw99sCKUG7NvJSBTpAtUgdAyD 8KsFLuMdeUCrjgxSPRZP4jJ/wXnOElg+JO6ArFvPTlWGVOGhHFHaMbgSHFnidTCGF6oy qHhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721023732; x=1721628532; 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=dm/k7gFIMhdyfC4SGzvRbrKukaD9JWCFWZBHyaB3OaE=; b=um0MobV+jc7zI9e/t9r/VryddxIi+iX703mFjv99fZfOY5+gOCmBv1SFRqPdW6M4Yv hzvN6B3j/plF1SeqITyXbFgz3K8tySMaWk0MKpvZGkxhV99VQsKTt4OsFE0yPZWeiYyq +2nsszw+4ysBtqQStHINDWTbZZ1ng1ukBttVIhd0lTO7+y695pBEswwGcvsO7JFf5Tp6 1POv71USMU+PX4EPIxadWTsBOg536iGuSaUOzS8FzDZ16EbFXW6EA0SXaDyYgogAxMef LFwDEkcYotsmOa2ZSIUi36IeA1Whva1w3TOINwTlqeUGUPjoLErj3hpi1xyv8tXPl2u7 IQ+w== X-Forwarded-Encrypted: i=1; AJvYcCXODgj0GwoTbrNqPryYoZhPcSLka7gr0Jw3096/TY0ZVdT0vWNdPR233M8TOtaddVsMRW494udUS4YR2zLcCz+rCzm/WIM/ulfnJ4RN+quE/Yve X-Gm-Message-State: AOJu0Yz6WCHT+kL6bkUxOvInB2g5ImdzRr9fZp4juPipxHmB/+vQ2o6w 72iy2y2Go0VjgCla7YzVpRQx17orLmhbIKkC4W6cVUfqAGhLX8Jc X-Google-Smtp-Source: AGHT+IFERNyNZT+5JeA01yPwtIvQaf5ht6M7R7Ucy45KNtQt9jWf3gH1pPiTR2dFw1rowtLZxFUotg== X-Received: by 2002:a05:6512:3c8c:b0:52e:9a4f:2050 with SMTP id 2adb3069b0e04-52eb99d15d8mr13620986e87.45.1721023731691; Sun, 14 Jul 2024 23:08:51 -0700 (PDT) Received: from [10.10.20.99] (node-boq.pool-113-53.dynamic.totinternet.net. [113.53.59.42]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52ed252d73fsm736982e87.132.2024.07.14.23.08.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 14 Jul 2024 23:08:51 -0700 (PDT) Message-ID: <6da9bdb2-3ff2-4b8b-818a-8052772f2163@gmail.com> Date: Mon, 15 Jul 2024 13:08:43 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Removing unneeded self joins To: jian he , Alexander Korotkov Cc: Tom Lane , Robert Haas , Andrei Lepikhov , Richard Guo , Alexander Lakhin , "Gregory Stark (as CFM)" , =?UTF-8?Q?Micha=C5=82_K=C5=82eczek?= , PostgreSQL Hackers References: <64486b0b-0404-e39e-322d-0801154901f3@postgrespro.ru> <2422119.1714691974@sss.pgh.pa.us> <24e93efd-eeac-43a6-a75a-ad68eacb32ee@postgrespro.ru> <3622801.1715010885@sss.pgh.pa.us> <96250a42-20e3-40f0-9d45-f53ae852f8ed@gmail.com> <5b49501c-9cb3-4c5d-9d56-49704ff08143@gmail.com> Content-Language: en-AU From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/15/24 12:31, jian he wrote: > hi. > Here is the latest patch (v6), > I've made the following changes. > > * disallow original Query->resultRelation participate in SJE. > for SELECT, nothing is changed. for UPDATE/DELETE/MERGE > we can do: > EXPLAIN (COSTS OFF) > UPDATE sj sq SET b = sq.b + sz.a FROM (select s1.* from sj s1 join sj > s2 on s1.a = s2.a) as sz > WHERE sz.a = sq.a; > > here, only "(select s1.* from sj s1 join sj s2 on s1.a = s2.a)" can > apply to SJE. > > but for now we cannot apply SJE to > EXPLAIN (COSTS OFF) > UPDATE sj sq SET b = sq.b + sz.a FROM sj as sz WHERE sz.a = sq.a; > > so the EPQ abnormality issue[1] won't happen. > > > * add a new function: ChangeVarNodesExtended for > address concerns in [2] I see you still stay with the code line: if (omark && imark && omark->markType != imark->markType) It is definitely an error. What if omark is NULL, but imark is not? Why not to skip this pair of relids? Or, at least, insert an assertion to check that you filtered it earlier. -- regards, Andrei Lepikhov