Received: from email04.aon.at (WARSL402PIP5.highway.telekom.at [195.3.96.79]) by postgresql.org (Postfix) with SMTP id 33152474E4E for ; Thu, 11 Jul 2002 14:47:27 -0400 (EDT) Received: (qmail 409734 invoked from network); 11 Jul 2002 18:46:16 -0000 Received: from m150p015.dipool.highway.telekom.at (HELO cantor) ([62.46.8.175]) (envelope-sender ) by qmail5rs.highway.telekom.at (qmail-ldap-1.03) with SMTP for ; 11 Jul 2002 18:46:16 -0000 From: Manfred Koizar To: "Luis Alberto Amigo Navarro" Cc: Subject: Re: [HACKERS] please help on query Date: Thu, 11 Jul 2002 20:44:58 +0200 Message-ID: <47jriu8760vo9n9a4ffvtl165ebe7rvksj@4ax.com> References: <005e01c228ee$bd1913e0$cab990c1@atc.unican.es> <007c01c22902$16e699c0$cab990c1@atc.unican.es> In-Reply-To: <007c01c22902$16e699c0$cab990c1@atc.unican.es> X-Mailer: Forte Agent 1.8/32.548 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200207/168 X-Sequence-Number: 8547 On Thu, 11 Jul 2002 19:40:46 +0200, "Luis Alberto Amigo Navarro" wrote: >I've tried [reformatted to fit on one page] | SELECT supplier.name, supplier.address | FROM supplier, nation, lineitem You already found out that you do not need lineitem here. | WHERE EXISTS( | SELECT partsupp.suppkey | FROM partsupp,lineitem | WHERE | lineitem.partkey=partsupp.partkey | AND lineitem.suppkey=partsupp.partkey I still don't believe this suppkey=partkey | AND lineitem.shipdate [...] | AND EXISTS( SELECT part.partkey | FROM part WHERE part.name like 'forest%') This subselect gives either true or false, but in any case always the same result. You might want to add a condition AND part.partkey=partsupp.partkey Are you sure partkey is not unique? If it is unique you can replace this subselect by a join. | GROUP BY partsupp.partkey,partsupp.suppkey | HAVING min(availqty)>(0.5*(sum(lineitem.quantity)::FLOAT)) | ) | AND supplier.nationkey=nation.nationkey | AND nation.name='CANADA' | ORDER BY supplier.name; >as you said and something is wrong >Sort (cost=1141741215.35..1141741215.35 rows=2400490000 width=81) The cost is now only 1141741215.35 compared to 2777810917708.17 before; this is an improvement factor of more than 2000. So what's your problem? ;-) Servus Manfred