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 1lyqKi-0003Dj-SF for pgsql-hackers@arkaria.postgresql.org; Thu, 01 Jul 2021 06:37:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lyqKh-0007E7-NZ for pgsql-hackers@arkaria.postgresql.org; Thu, 01 Jul 2021 06:37:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lyqKh-0007Dz-Ed for pgsql-hackers@lists.postgresql.org; Thu, 01 Jul 2021 06:37:55 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lyqKf-00007k-6o for pgsql-hackers@lists.postgresql.org; Thu, 01 Jul 2021 06:37:54 +0000 Received: by mail-wr1-x42b.google.com with SMTP id g7so6638179wri.7 for ; Wed, 30 Jun 2021 23:37:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aiven.io; s=google; h=from:to:cc:subject:date:message-id:organization:in-reply-to :references:mime-version:content-transfer-encoding; bh=rMo2MOniKbLq+TWL7TF/TbFxDuBJax7KkpAUYkINjLk=; b=iUBpu83PG7llWEYSEs6i52t389sIBIpk0eQYb9XsD72xExkZVwKa/Clc3sLXkK9O73 SgYOK58eGugxwRf3uP7iK9PsImOsEsr4BkIxo0YtGR8mt1vrrAr+uqiVcEEZSE0A7DMK 2PPzvEvBxqwoVoyzGDeQgYGyD015azubqOklo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :in-reply-to:references:mime-version:content-transfer-encoding; bh=rMo2MOniKbLq+TWL7TF/TbFxDuBJax7KkpAUYkINjLk=; b=EedGiSybigKZb3MJTRIUlE9AVh9g0WmbHAIrJXnlcttU/gVsyP/jYeQ6aYDX+B7K5V HZij91ICia1zkw5548zzipGiWOTVzyzlC1nstnzLY9ToMQe/tgFkCbX8r/cZKZvhaN4i vTiHWJTRSldogkJo10YPZ0dd2o34kvHs93p5g4QGbjj/bA8AFAXGjHY5qwa7U0gXC2yr GssPuILK0mkB2HeoUfmqT12WQDczqQJOsyyL3HLttrPz/E+LvUhvJ4pizNQwo62v19Mr j0KC9OFx6PqdOe3wLJmlgMuLKt1bSthMtq3ZYcYOhP/XN3AUKka6CuR19YmRbH8nFSsx wnTQ== X-Gm-Message-State: AOAM531RuBRdQsBgq8kvnS9Wp5bGrxy/HVbVbG1w18+LuxqGYuSZwJuJ CIgJke4BR0Y0xh0W3mVN7ctSCQ== X-Google-Smtp-Source: ABdhPJwhl7hbF6eBYcbHyI80NrMotmnDKCbOws4KrV+wyzFDCoxnGxSs8DlON46wzHiZN1SJj96Vqg== X-Received: by 2002:a05:6000:18ca:: with SMTP id w10mr43573227wrq.55.1625121471511; Wed, 30 Jun 2021 23:37:51 -0700 (PDT) Received: from aivenronan.localnet (static-176-158-121-96.ftth.abo.bbox.fr. [176.158.121.96]) by smtp.gmail.com with ESMTPSA id g15sm23717468wri.75.2021.06.30.23.37.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 23:37:51 -0700 (PDT) From: Ronan Dunklau To: Laurenz Albe Cc: Andrey Lepikhov , Hywel Carver , pgsql-hackers@lists.postgresql.org, Konstantin Knizhnik Subject: Re: Removing unneeded self joins Date: Thu, 01 Jul 2021 08:37:46 +0200 Message-ID: <4911774.fQZKmtWmdp@aivenronan> Organization: aiven In-Reply-To: References: <64486b0b-0404-e39e-322d-0801154901f3@postgrespro.ru> <2a6e540a-4c9f-9402-2e02-71e35fcd4dd1@postgrespro.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > Generally I have the impression that we are not too keen on spending > planning time on optimizing cases that can be trivially improved by > rewriting the query. Well in some cases they can't, when the query is not emitting redundant predicates by itself but they are added by something else like a view or a RLS policy. Maybe it would be worth it to allow spending a bit more time planning for those cases ? Regards, -- Ronan Dunklau