Article View: borland.public.interbase.sql
Article #368Different Plans with the same SQL Statement
From: Peter Batten
Date: Tue, 22 Apr 2008 00:46
Date: Tue, 22 Apr 2008 00:46
36 lines
2130 bytes
2130 bytes
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
Technical Details
Message-ID:
<480d3572$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,20467dbf75a0f9c4,start X-Google-Attributes: gid114a0e,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Peter Batten" <datafast@tpgi.com.au> From: "Peter Batten" <datafast@tpgi.com.au> Newsgroups: borland.public.interbase.sql Subject: Different Plans with the same SQL Statement Date: Tue, 22 Apr 2008 10:46:07 +1000 Lines: 41 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1914 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1914 NNTP-Posting-Host: 60.241.152.140 Message-ID: <480d3572$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1208825202 60.241.152.140 (21 Apr 2008 17:46:42 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail X-Original-Bytes: 1967