pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jim Finnerty <jfinnert@amazon.com>
To: pgsql-general@postgresql.org
Subject: Re: Removing INNER JOINs
Date: Mon, 11 Dec 2017 06:38:03 -0700 (MST)
Message-ID: <1512999483420-0.post@n3.nabble.com> (raw)
In-Reply-To: <CAKJS1f_bczvo=6zsh1FU6Ayj1FV9OT0gD_CMvxN1JNW9k+Eruw@mail.gmail.com>
References: <VisenaEmail.2b.7dfa64bdab147c49.1600d1d9df0@tc7-visena>
	<CAKJS1f9FToa68cr_DETV=utG6xqokXYm+yQ=-PpVj9aPkGXanw@mail.gmail.com>
	<CANP8+jKTPQqiUEba6WZ4dd+ca=UrhbJ1BEUv080bs6Gy-tXKQQ@mail.gmail.com>
	<CAKJS1f-5UrL0R-z5TQnJ37YkgU9RwkDHW4NSkL+ZO3adUDLzQQ@mail.gmail.com>
	<1512966801439-0.post@n3.nabble.com>
	<CAKJS1f_bczvo=6zsh1FU6Ayj1FV9OT0gD_CMvxN1JNW9k+Eruw@mail.gmail.com>

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




view thread (10+ messages)  latest in thread

Message-ID: <1512999483420-0.post@n3.nabble.com>
Permalink:  ../1512999483420-0.post@n3.nabble.com/
Also on:    postgresql.org/message-id/1512999483420-0.post@n3.nabble.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: jfinnert@amazon.com
  Subject: Re: Removing INNER JOINs
  In-Reply-To: <1512999483420-0.post@n3.nabble.com>
  References: <VisenaEmail.2b.7dfa64bdab147c49.1600d1d9df0@tc7-visena> <CAKJS1f9FToa68cr_DETV=utG6xqokXYm+yQ=-PpVj9aPkGXanw@mail.gmail.com> <CANP8+jKTPQqiUEba6WZ4dd+ca=UrhbJ1BEUv080bs6Gy-tXKQQ@mail.gmail.com> <CAKJS1f-5UrL0R-z5TQnJ37YkgU9RwkDHW4NSkL+ZO3adUDLzQQ@mail.gmail.com> <1512966801439-0.post@n3.nabble.com> <CAKJS1f_bczvo=6zsh1FU6Ayj1FV9OT0gD_CMvxN1JNW9k+Eruw@mail.gmail.com> <1512999483420-0.post@n3.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox