🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #372

Re: Different Plans with the same SQL Statement

#372
From: Quinn Wildman (CodeGear Develope...
Date: Tue, 22 Apr 2008 15:14
45 lines
2357 bytes
InterBase 2007 SP2 specifically addressed the optimizer, so plans with 
it may be different. Hopefully, they are usually better.

Peter Batten wrote:
> 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: <480e0119$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mail
References: <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-7-bit
Date: Tue, 22 Apr 2008 08:14:51 -0700
From: "Quinn Wildman (CodeGear Developer Support)" <qwildman@nospam.codegear.com>
User-Agent: Thunderbird 1.5.0.14 (Windows/20071210)
MIME-Version: 1.0
Newsgroups: borland.public.interbase.sql
Subject: Re: Different Plans with the same SQL Statement
References: <480d3572$1@newsgroups.borland.com>
In-Reply-To: <480d3572$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 10.143.100.209
Message-ID: <480e0119$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1208877337 10.143.100.209 (22 Apr 2008 08:15:37 -0700)
Lines: 45
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mail