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 1tzBii-00GNwi-7S for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Mar 2025 09:46:16 +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 1tzBig-003ESd-CI for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Mar 2025 09:46:14 +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 1tzBif-003ESU-QP for pgsql-hackers@lists.postgresql.org; Mon, 31 Mar 2025 09:46:13 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tzBid-0026xS-2y for pgsql-hackers@postgresql.org; Mon, 31 Mar 2025 09:46:12 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-43690d4605dso27838805e9.0 for ; Mon, 31 Mar 2025 02:46:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743414370; x=1744019170; darn=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=9WQv1BMZnh/9hBFPFa24hdNQxYdXexzb9r3Q2P/slDE=; b=TytLGAo2ToIsmOHfdwZvZABUUVozllaLm/wmnI+TPg040iF/k2Aa+ygSiTUPx/1mVj LEhQUk2xvuYaBhzbB+hyCej30Sbrz7TpF0PVmkOEzh8vDE562Vg5074KiKkKR8bGlgVT fzWnX6xXDEbnUOpYcyNdidMOfam0vliBXY/ArSm4MvekMomDoxgY4jHsmBxJXBvQm8pl kK2DX9dTQkWuVavE1p+v2QNG7jtZzWl//oRTQOBHVAuX4oe1o9O1DN8HOP1W9pOtUNyw m6r+aXRp1g4T/HeX0Naa4gie4rtvOwa8SbuXuSdZ66LifDV1BQsYIjTw47DBvvg6TQtR Ee8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743414370; x=1744019170; 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=9WQv1BMZnh/9hBFPFa24hdNQxYdXexzb9r3Q2P/slDE=; b=TxLXOYKf4oaIzReeL2PDupKoq/8xJMmisPCJtTe8xytVQ1Pdzpfg3tim34y2BNsZnP CNibGDzNsH5C5xqRaAisJz87tss6Xv65k8y5Nrz5Crw4AopLelBktqXuXk56uoCStz1F y5v7YXc8ltTHHFyBL5TyM1mNIaAdEMBu88oO9Xlcd6bZuMudUzV7xD4WWTHxujdgjJfy HDNB+DLbM/3mt2hm+3iWMkWkj0z0jiPyNNXiQhTXH2wnmKyIfSUUX58694QU7nYyODz3 1FXgoBAcjzzwjuZ0CckUQmXvPZny+bgd4BFhXimcIVWMEg7wKxfB770kca/ol3m/SzKp JHdw== X-Gm-Message-State: AOJu0YzT9IetkA2JzQ/C7EfJjf4+URmpB0ouEgct9ZHBI354ner+Z5CM FiHTph7w4yr0cOZ6EA/k+zeX02HtRVVTOv8bgnSQtFAXa6i+TiOe X-Gm-Gg: ASbGncvKlzqdXYicw8I2bceWPjIFD98MIyHvr0M07HDDTR5TCpHcRsLnDCGhOsinQKA iDKxBJvBtq/ShA8sVn1WO62nnnf5Vf+zQcrRU7QY6HTL0WUQdQnXOaZrvQ1fMUedE6HnysPEY9q k8GBhc0NDFdkE4kFnwbx1IwF4JOOEzW8p6zh48qYeCB6FLjXrwcqhiOrKMqN2+PlxBw/PxTYauX ePz7sePBM2v+/ihuNlGq52QzoPkzaq2KuozC/gLwQhYGxPLpKeUBPNQ76jRmU+MXwQFeRybskm9 75dUV8nJRGAicMwWc9/pIcDOmd9HpYFnFv/uTYikwCAiAU2+y+FXGZTsw9Bl9UYxOCg63mZKPwH 3AYQ= X-Google-Smtp-Source: AGHT+IH0o9Gn6VV7rrEXywdUmu6NUNH2ynJlfz1d4t29tovc5JIEn2MomZnQ4Jf50vUj0ryBUDdxxw== X-Received: by 2002:a05:600c:83c4:b0:439:91dd:cf9c with SMTP id 5b1f17b1804b1-43db6223feamr106059755e9.10.1743414370069; Mon, 31 Mar 2025 02:46:10 -0700 (PDT) Received: from [192.168.0.89] (84.123.232.230.dyn.user.ono.com. [84.123.232.230]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d82dedc2dsm158877005e9.2.2025.03.31.02.46.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 Mar 2025 02:46:09 -0700 (PDT) Message-ID: <1b356b61-3a2a-490a-bf9a-6340a1ec004a@gmail.com> Date: Mon, 31 Mar 2025 11:46:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Memoize ANTI and SEMI JOIN inner To: Richard Guo , David Rowley Cc: PostgreSQL-development References: <60bf8d26-7c7e-4915-b544-afdb9020011d@gmail.com> <95586c5d-2632-4f1c-bfb9-4c391f260de4@gmail.com> 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 3/31/25 11:03, Richard Guo wrote: > On Thu, Mar 20, 2025 at 3:02 PM David Rowley wrote: >> For making this work, I think the attached should be about the guts of >> the code changes. I didn't look at the comments. Right now I can't >> think of any reason why this can't be done, but some experimentation >> might reveal some reason that it can't. > > I reviewed this patch and I have some concerns about the following > code: > > if (extra->inner_unique && > (inner_path->param_info == NULL || > bms_num_members(inner_path->param_info->ppi_serials) < > list_length(extra->restrictlist))) > return NULL; > > I understand that this check is used to ensure that the entire join > condition is parameterized in the case of unique joins, so that we can > safely mark the cache entry as complete after reading the first tuple. > However, ppi_clauses includes join clauses available from all outer > rels, not just the current outer rel, while extra->restrictlist only > includes the restriction clauses for the current join. This means the > check could pass even if a restriction clause isn't parameterized, as > long as another join clause, which doesn't belong to the current join, > is included in ppi_clauses. Initially, I had the same concern. But if ppi_clauses contains a qual, it should refer to this join and, as a result, be in the extra->restrictlist, isn't it? I thought about references to the other side of an OUTER JOIN, but if the subquery refers to LHS, it just not be transformed to the SEMI/ANTI join. Anyway, if you provide an example or just a sketch, I will be happy to discover it. -- regards, Andrei Lepikhov