Article View: borland.public.interbase.sql
Article #638Re: optimizing query ..
From: Karol Bieniaszewski
Date: Tue, 18 Sep 2007 12:51
Date: Tue, 18 Sep 2007 12:51
51 lines
2375 bytes
2375 bytes
U�ytkownik "Wayne Niddery [TeamB]" <wniddery@chaffaci.on.ca> napisa� w wiadomo�ci news:46ee8f07@newsgroups.borland.com... > Karol Bieniaszewski wrote: >> >>> I would try this: >>> >>> FROM >>> TABLE_C C >>> INNER JOIN TABLE_A A ON A.ID=C.ID_OBJ >>> INNER JOIN TABLE_B B ON B.ID_OBJ=C.ID_OBJ AND B.SYSTEM=C.SYSTEM >>> LEFT JOIN TABLE_D D ON D.NAZWA=C.ALARM >>> WHERE >>> C.ZRODLO=:PARAM_X >>> AND B.KOD=:PARAM_Y >>> AND B.SYSTEM=:PARAM_Z >> >> now plan is :( >> PLAN JOIN (JOIN (A NATURAL,C INDEX (IXA_TABLE_C__OBJ__ZRO__SYS),B >> INDEX (IXA_TABLE_B__KOD__SYSTEM, FK_TABLE_B__ID_OBJ)),D INDEX >> (IXAU__TABLE_D__NAZWA)) > > You could try making A a left join. If there is always a match, the result > set will be the same, if there could be C's without a matching A then add > a condition to the where clause : ' A.ID is not null'. > this does not change anything in last query but do the trick (left join) in query like this SELECT * FROM TABLE_B B LEFT JOIN TABLE_A A ON B.ID_OBJ=A.ID INNER JOIN TABLE_C C ON C.ID_OBJ=A.ID AND B.SYSTEM=C.SYSTEM AND C.ZRODLO=:PARAM_X LEFT JOIN TABLE_D D ON C.ALARM=D.NAZWA WHERE B.KOD=:PARAM_Y AND B.SYSTEM=:PARAM_Z PLAN JOIN (JOIN (JOIN (B INDEX (IXA_OBIEKTST_DB__KOD__SYSTEM),A INDEX (PK_ADRESY_DB__ID)),C INDEX (IXA_ELEMSTAN_DB__OBJ__ZRO__SYS)),SA INDEX (IXAU__SLAL_DB__NAZWA)) greate thanks Karol Bieniaszewski
Technical Details
Message-ID:
<46efc85d$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<46ea51f5$1@newsgroups.borland.com> <46ea9edd$1@newsgroups.borland.com> <46ee4c91$1@newsgroups.borland.com> <46ee8f07@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,27cb88e47143e0c2 X-Google-Attributes: gid114a0e,public,usenet X-Google-Language: ENGLISH,ASCII From: "Karol Bieniaszewski" <liviuslivius@poczta.onet.pl> Newsgroups: borland.public.interbase.sql References: <46ea51f5$1@newsgroups.borland.com> <46ea9edd$1@newsgroups.borland.com> <46ee4c91$1@newsgroups.borland.com> <46ee8f07@newsgroups.borland.com> Subject: Re: optimizing query .. Date: Tue, 18 Sep 2007 14:51:47 +0200 Lines: 53 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 195.205.151.58 Message-ID: <46efc85d$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1190119517 195.205.151.58 (18 Sep 2007 05:45:17 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail