pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sven R. Kunze <srkunze@mail.de>
To: Pavel Stehule <pavel.stehule@gmail.com>
To: pgsql-performance@postgresql.org
Subject: Re: Multiple-Table-Spanning Joins with ORs in WHERE Clause
Date: Thu, 29 Sep 2016 14:20:31 +0200
Message-ID: <8ccdd027-f4a0-2e0d-1e26-2a403fed8d17@mail.de> (raw)
In-Reply-To: <CAFj8pRADRasfgjOoXXdKTMKvab9=ypmp-9uoCMAsGBvA5F5tqg@mail.gmail.com>
References: <97dbd6f9-a289-94d1-325f-997df87c672a@mail.de>
	<fc49b4e6-8912-2a8d-4f58-7d1ed455cb49@ed.ac.uk>
	<0e86e399-61dc-8e78-415e-c83db9592a80@mail.de>
	<CAFj8pRADRasfgjOoXXdKTMKvab9=ypmp-9uoCMAsGBvA5F5tqg@mail.gmail.com>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>

On 23.09.2016 11:00, Pavel Stehule wrote:
> 2016-09-23 8:35 GMT+02:00 Sven R. Kunze <srkunze@mail.de 
> <mailto:srkunze@mail.de>>:
>
>     I was wondering: would it be possible for PostgreSQL to rewrite
>     the query to generate the UNION (or subquery plan if it's also
>     fast) on it's own?
>
>
> It depends on real data. On your specific data the UNION variant is 
> pretty fast, on different set, the UNION can be pretty slow. It is 
> related to difficult OR predicate estimation.

I figure that the UNION is fast if the sub-results are small (which they 
are in our case). On the contrary, when they are huge, the OUTER JOIN 
variant might be preferable.


Is there something I can do to help here?

Or do you think it's naturally application-dependent and thus should be 
solved with application logic just as we did?


Cheers,
Sven

view thread (17+ messages)  latest in thread

Message-ID: <8ccdd027-f4a0-2e0d-1e26-2a403fed8d17@mail.de>
Permalink:  ../8ccdd027-f4a0-2e0d-1e26-2a403fed8d17@mail.de/
Also on:    postgresql.org/message-id/8ccdd027-f4a0-2e0d-1e26-2a403fed8d17@mail.de

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: srkunze@mail.de, pavel.stehule@gmail.com
  Subject: Re: Multiple-Table-Spanning Joins with ORs in WHERE Clause
  In-Reply-To: <8ccdd027-f4a0-2e0d-1e26-2a403fed8d17@mail.de>

* 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