Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOOL2-0002GP-Jp for pgsql-general@arkaria.postgresql.org; Mon, 11 Dec 2017 13:41:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOOL2-00068a-3t for pgsql-general@arkaria.postgresql.org; Mon, 11 Dec 2017 13:41:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eOOHZ-0000On-58 for pgsql-general@lists.postgresql.org; Mon, 11 Dec 2017 13:38:09 +0000 Received: from n3.nabble.com ([162.255.23.22]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eOOHV-0004df-SO for pgsql-general@postgresql.org; Mon, 11 Dec 2017 13:38:08 +0000 Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id 674DAA014B4F for ; Mon, 11 Dec 2017 06:38:03 -0700 (MST) Date: Mon, 11 Dec 2017 06:38:03 -0700 (MST) From: Jim Finnerty To: pgsql-general@postgresql.org Message-ID: <1512999483420-0.post@n3.nabble.com> In-Reply-To: References: <1512966801439-0.post@n3.nabble.com> Subject: Re: Removing INNER JOINs MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Great example, David. The planner can detect whether a SELECT statement contains a volatile function, and can disable the proposed redundant inner-join optimization in that case. If necessary, the planner could also check that the FK constraint is not DEFERRED, but if there are no volatile functions and the SELECT statement can't see an inconsistent state created by any other transaction, I think that just checking for volatile functions and not being inside a DML transaction would be sufficient. A further opportunity would be to apply this to any SELECT statement in a DML transaction, provided that there was no prior DML statement or statement containing a volatile function in the same transaction. We already have a redundant outer join optimization, and I've implemented the redundant inner join optimization in two other products before, so adding the additional logic to support the inner join case(s) sounds straightforward to me. Can anyone think of any other problem scenarios? /Jim F -- Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html