Article View: borland.public.interbase.sql
Article #369Re: Different Plans with the same SQL Statement
From: Karol Bieniaszewski
Date: Tue, 22 Apr 2008 09:27
Date: Tue, 22 Apr 2008 09:27
47 lines
2540 bytes
2540 bytes
U�ytkownik "Peter Batten" <datafast@tpgi.com.au> napisa� w wiadomo�ci news:480d3572$1@newsgroups.borland.com... >I have code which looks like > > Select * from PERSONAL p , LINKPERSADDR lpa, ADDRESS a , LINKADDRTELE lat, > TELEPHONY t > where t.UPPERPACKEDNUMBER Starting With "0385316661" and > p.PERSONALAUTONO = lpa.PERSONALAUTONO and > lpa.ADDRESSAUTONO = a.ADDRESSAUTONO and > lat.ADDRESSAUTONO = a.ADDRESSAUTONO and > t.TELEPHONYAUTONO = lat.TELEPHONYAUTONO > order by p.UPPERNAME > > On one machine running IB 8.1.0.257 this returns a plan of > > PLAN SORT (JOIN (A NATURAL,LPA INDEX (LINKADDRPERS),P INDEX > (RDB$PRIMARY5),LAT INDEX (RDB$PRIMARY24),T INDEX > (UPPERTELEPACKEDNUMBER,RDB$PRIMARY6))) > which is using Natural on ADDRESS A and is terribly slow > > But on a different machine running IB 8.0.0.123 > version > I get a plan of > PLAN SORT (JOIN (T INDEX (UPPERTELEPACKEDNUMBER),LAT INDEX > (LINKTELEADDR),A > INDEX (RDB$PRIMARY1),LPA INDEX (LINKADDRPERS),P INDEX (RDB$PRIMARY5))) > and very fast. > > All indexes exist on each machine. > > Why are these two different plans generated. I don't particularly want to > add a plan statement to the statement as this is generated on the fly and > would need many conditionals to build the correct plan each time. > > Any help appreciated > > Regards > > Peter > try copy database to second computer and test if plans are the same 1. if yes then i suppose that is some difference in 2 databases eg. different statistics on indexes, diferent ODS structure 2. if are different then problem is with newer version of IB :/ Karol Bieniaszewski
Technical Details
Message-ID:
<480dad69@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<480d3572$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,20467dbf75a0f9c4 X-Google-Attributes: gid114a0e,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII From: "Karol Bieniaszewski" <liviuslivius@poczta.onet.pl> Newsgroups: borland.public.interbase.sql References: <480d3572$1@newsgroups.borland.com> Subject: Re: Different Plans with the same SQL Statement Date: Tue, 22 Apr 2008 11:27:59 +0200 Lines: 50 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.3198 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 195.205.151.58 Message-ID: <480dad69@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1208855913 195.205.151.58 (22 Apr 2008 02:18:33 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail