Received: (qmail 9375 invoked from network); 9 Sep 2011 03:24:53 -0500
Received: from freelists-180.iquest.net (HELO turing.freelists.org) (206.53.239.180)
  by static-ip-85-25-126-90.inaddr.ip-pool.com with SMTP; 9 Sep 2011 03:24:49 -0500
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 05C9EE406A3;
 Fri,  9 Sep 2011 04:22:11 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=freelists.org;
 s=turing; t=1315556531; bh=qU8xR/wyn0J+BTV2g/HYIsd2ae96CSNj9d1Ydns6
 c4A=; h=Message-ID:From:To:References:Subject:Date:MIME-Version:
	 Content-type:Content-Transfer-Encoding:Sender:Reply-To:List-help:
	 List-unsubscribe:List-Id:List-subscribe:List-owner:List-post:
	 List-archive; b=XS8bO0wIPsiPX0jX3oRYRvHKa3ByV2JouNfmf02U8RX1VDSvCZ
 RfEVfIzaV7RUeJ7+ZwJnsw8OZ6aiuNgdIebQqU7Y8z6dxUp9uLHxp7Mp2L97dgFFJnC
 VC6eQFWG+amHWNFyJtDHR/UNVxMRgzZI+9VHKMT3EzBL9BL+vMIP2k=
X-Virus-Scanned: Debian amavisd-new at localhost.localdomain
Received: from turing.freelists.org ([127.0.0.1])
 by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 6naiI+JJOpnP; Fri,  9 Sep 2011 04:22:10 -0400 (EDT)
Received: from turing.freelists.org (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 7C276E40670;
 Fri,  9 Sep 2011 04:21:27 -0400 (EDT)
Received: with ECARTIS (v1.0.0; list oracle-l); Fri, 09 Sep 2011 04:20:45 -0400 (EDT)
Received: from localhost (localhost [127.0.0.1])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id DEF09E40668
 for <oracle-l@freelists.org>; Fri,  9 Sep 2011 04:20:44 -0400 (EDT)
Authentication-Results: turing.freelists.org; dkim=pass (1024-bit key) header.i=@yahoo.com
Received: from turing.freelists.org ([127.0.0.1])
 by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 15zEQcxaR3e6 for <oracle-l@freelists.org>;
 Fri,  9 Sep 2011 04:20:44 -0400 (EDT)
Received: from nm1.bt.bullet.mail.ukl.yahoo.com (nm1.bt.bullet.mail.ukl.yahoo.com [217.146.183.199])
 by turing.freelists.org (Avenir Technologies Mail Multiplex) with SMTP id 43798E3EAF5
 for <oracle-l@freelists.org>; Fri,  9 Sep 2011 04:20:11 -0400 (EDT)
Received: from [217.146.183.195] by nm1.bt.bullet.mail.ukl.yahoo.com with NNFMP; 09 Sep 2011 08:17:00 -0000
Received: from [217.146.183.206] by tm1.bt.bullet.mail.ukl.yahoo.com with NNFMP; 09 Sep 2011 08:17:00 -0000
Received: from [127.0.0.1] by omp1004.bt.mail.ukl.yahoo.com with NNFMP; 09 Sep 2011 08:17:00 -0000
X-Yahoo-Newman-Id: 653213.83173.bm@omp1004.bt.mail.ukl.yahoo.com
Received: (qmail 2389 invoked from network); 9 Sep 2011 08:17:00 -0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1315556220; bh=9Abgr6WYi7xYwAbT7miam98VcmIMSS9lfqwIiDps/Js=; h=X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Message-ID:From:To:References:Subject:Date:MIME-Version:Content-Type:Content-Transfer-Encoding:X-Priority:X-MSMail-Priority:X-Mailer:X-MimeOLE; b=Q4MdmzJow9LGbXEjpHLpUwAribSD4lzw4RwwOauSftYkAVDITorvWwQF5upwI3cgEab0SMPuFtZST/VTPs/FihvJVvV9bEMHSeRn+I5f7am38X060bUmxjDkoYlFOcnJp850y5tmJJa2offf1rG0P1vuhCeqS881BL8zNbdv2LU=
X-Yahoo-Newman-Property: ymail-3
X-YMail-OSG: ugZencEVM1mRgRSMbhr_z2mBG142ILQn46TEko75V0ugSuj
 qgTTbvwFcpAZGzYveDO.mvCLAt2qqcfjbgdS6nMjxeMjLH.yCbdKVuTKYCC2
 p3WbgpchnCQiPuKaaDdGMZ8B7TZu.O0OfrGl29rSD5z_hIF_LmTsKfNQFbLr
 v0c6owXz6qZ1To9wd7gwTAVem2zP5u2MIApmAWtnq_ZBrn3z6FajFqIoyb6G
 7ppUN7VcvgVk8xQmgzpEgbSY6iN_Qb2Z6bMSEvmJhFueB8PgOseI52VkeSe6
 VnzLUSOrz5n8iShfTVxDLvZVcelZ0APtf3dCnn0Byj5_4SKgP4jZq2KNzO6q
 qvioL060uccZTwgXTc9a2Dmh1LwcVIH9fDaipTCp170SfqaR71MbjS9JBG79
 5AjnFkBqgM80WV0q1j9Nkc.htO9a1KDERmhUrl3JU43o22LDXUIee9z42nH3
 aHTwJCLGIe9cjALkY3ujvYAAOQYRbzN1EpqrmaLhHaHRIl6sEA1ucpA--
X-Yahoo-SMTP: 4vWPFZSswBAs9FgodTSfpaeSlgxsILPLGEbCUJdD5X2Ag3l43R3FWMc-
Received: from Primary (jonathan@86.161.118.244 with login)
        by smtp822.mail.ukl.yahoo.com with SMTP; 09 Sep 2011 08:17:00 +0000 GMT
Message-ID: <840CC2221F934911BC8685C1400C7A7C@Primary>
From: "Jonathan Lewis" <jonathan@jlcomp.demon.co.uk>
To: "Oracle L" <oracle-l@freelists.org>
References: <D18D6513433DF04394041EA42B53E91C57884719@ICATEXCH2.ICAT.com> <4E69BFBE.6000803@roughsea.com>
Subject: Re: getting in a little over my head
Date: Fri, 9 Sep 2011 09:17:24 +0100
MIME-Version: 1.0
Content-type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109
X-archive-position: 38678
X-ecartis-version: Ecartis v1.0.0
Sender: oracle-l-bounce@freelists.org
Errors-to: oracle-l-bounce@freelists.org
X-original-sender: jonathan@jlcomp.demon.co.uk
Precedence: normal
Reply-To: jonathan@jlcomp.demon.co.uk
List-help: <mailto:ecartis@freelists.org?Subject=help>
List-unsubscribe: <oracle-l-request@freelists.org?Subject=unsubscribe>
List-software: Ecartis version 1.0.0
List-Id: oracle-l <oracle-l.freelists.org>
X-List-ID: oracle-l <oracle-l.freelists.org>
List-subscribe: <oracle-l-request@freelists.org?Subject=subscribe>
List-owner: <mailto:steve.adams@ixora.com.au>
List-post: <mailto:oracle-l@freelists.org>
List-archive: <http://www.freelists.org/archives/oracle-l>
X-list: oracle-l



Stephane,

It depends on the uniqueness constraints, of course, but I think (based on the 
information we have so far)
that the "UNION ALL" should be a "UNION".

FROM (select objectid objid, 'Quote' linktype
       FROM quote
       WHERE accountid = 128847
       union all
       select objectid objid, 'Policy' linktype
       FROM pol_policy
       WHERE accountid = 128847
         AND logid = 1) x

Regards

Jonathan Lewis
http://jonathanlewis.wordpress.com


----- Original Message ----- 
From: "Stephane Faroult" <sfaroult@roughsea.com>
To: <JSweetser@icat.com>
Cc: "Oracle L" <oracle-l@freelists.org>
Sent: Friday, September 09, 2011 8:26 AM
Subject: Re: getting in a little over my head


Joe,
     I have never been a great fan of execution plans but I have always
hated multiple subqueries that kind of "sequentialize" everything. For
me, everything depends in your query about the selectivity of accountid
in tables quote and pol_policy, and my gut instinct would make me
rewrite your query like this:


--
http://www.freelists.org/webpage/oracle-l


