Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U7kI0-0001vY-Pk for pgsql-performance@arkaria.postgresql.org; Tue, 19 Feb 2013 10:19:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U7kI0-0007Tf-AW for pgsql-performance@arkaria.postgresql.org; Tue, 19 Feb 2013 10:19:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U7kHz-0007TZ-AF for pgsql-performance@postgresql.org; Tue, 19 Feb 2013 10:19:07 +0000 Received: from p3plsmtpa06-09.prod.phx3.secureserver.net ([173.201.192.110]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U7kHs-0000vP-Of for pgsql-performance@postgresql.org; Tue, 19 Feb 2013 10:19:06 +0000 Received: from 192-168-1-8.tpgi.com.au ([14.200.134.250]) by p3plsmtpa06-09.prod.phx3.secureserver.net with id 2AJw1l0035QJy3y01AJwoo; Tue, 19 Feb 2013 03:18:57 -0700 Message-ID: <5123518F.30206@basenlily.me> Date: Tue, 19 Feb 2013 21:18:55 +1100 From: Bastiaan Olij User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Speed of exist References: <51231D10.1070101@basenlily.me> <51232A36.6000701@orprovision.com> <51232B90.2080504@basenlily.me> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Hi Pavel, That is what I've done in this particular case but there are parts where I use exist checks in this way that are very cumbersome to write out like that so I'm hoping there is a way to make the optimizer work with existence checks in this way. Cheers, Bastiaan Olij On 19/02/13 6:39 PM, Pavel Stehule wrote: > 2013/2/19 Bastiaan Olij : >> Hi Andy, >> >> I've tried that with the same result. One subquery works beautifully, >> two subqueries with an OR and it starts to do a sequential scan... > try to rewrite OR to two SELECTs joined by UNION ALL > > Pavel > -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance