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 10:25:40 -0400
Message-ID: <11504.1565965540@sss.pgh.pa.us> (raw)
In-Reply-To: <CACF7Wx3U_4o1EiBQzCr64u3DRXWAsJk5SxrD38KJ4hq111K=iA@mail.gmail.com>
References: <CACF7Wx0twq1scHAuc3Q7itp727nfYZsj6EWYvFf1zYYjG1nJNQ@mail.gmail.com>
<9725.1565963088@sss.pgh.pa.us>
<CACF7Wx3U_4o1EiBQzCr64u3DRXWAsJk5SxrD38KJ4hq111K=iA@mail.gmail.com>
Peter Grman <peter.grman@gmail.com> writes:
> yes, I think this query is right below the geqo_threshold. But as I said,
> when I change only the WHERE condition to use AND instead of OR it's
> resulting in a really fast and efficient query (same planning time, but
> ~1/500th-1/1000th execution time). So there should be something different,
> or?
Don't really see why that would surprise you. Using AND means that the
individual conditions can be applied as filters, if the planner knows
how to use any one of them as (say) an indexscan or join qual. When
you use OR, that isn't possible.
regards, tom lane
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: <11504.1565965540@sss.pgh.pa.us>
References: <CACF7Wx0twq1scHAuc3Q7itp727nfYZsj6EWYvFf1zYYjG1nJNQ@mail.gmail.com> <9725.1565963088@sss.pgh.pa.us> <CACF7Wx3U_4o1EiBQzCr64u3DRXWAsJk5SxrD38KJ4hq111K=iA@mail.gmail.com> <11504.1565965540@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