pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Grman <peter.grman@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Bad Estimate for complex query with JOINS on subselects and OR in where conditions
Date: Fri, 16 Aug 2019 09:44:48 -0400
Message-ID: <9725.1565963088@sss.pgh.pa.us> (raw)
In-Reply-To: <CACF7Wx0twq1scHAuc3Q7itp727nfYZsj6EWYvFf1zYYjG1nJNQ@mail.gmail.com>
References: <CACF7Wx0twq1scHAuc3Q7itp727nfYZsj6EWYvFf1zYYjG1nJNQ@mail.gmail.com>

Peter Grman <peter.grman@gmail.com> writes:
> our ORM with tenant separation enabled is creating the following query:

Ugh.

By my count there are nine joined tables in that query, which means
you're hitting the default join_collapse_limit.  Increasing that
setting might improve matters somewhat, though it won't fix the
bad rowcount estimate per se.

			regards, tom lane





view thread (4+ messages)  latest in thread

Message-ID: <9725.1565963088@sss.pgh.pa.us>
Permalink:  ../9725.1565963088@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/9725.1565963088@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, peter.grman@gmail.com
  Subject: Re: Bad Estimate for complex query with JOINS on subselects and OR in where conditions
  In-Reply-To: <9725.1565963088@sss.pgh.pa.us>
  References: <CACF7Wx0twq1scHAuc3Q7itp727nfYZsj6EWYvFf1zYYjG1nJNQ@mail.gmail.com> <9725.1565963088@sss.pgh.pa.us>

* 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