🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Plan for query from VIEW problem .. dynamic sql error sql error code = -104 Token unknown .. PLAN

#166
From: Karol Bieniaszewski
Date: Wed, 25 Jun 2008 05:18
51 lines
2662 bytes
Uzytkownik "Wayne Niddery (TeamB)" <wniddery@chaffaci.on.ca> napisal w 
wiadomosci news:48612e73@newsgroups.borland.com...
> "Karol Bieniaszewski" <liviuslivius@poczta.onet.pl> wrote in message 
> news:4860e8bb$1@newsgroups.borland.com...
>>
>> but if i try
>>
>> select
>> *
>> from
>> XXX B
>> PLAN (B A NATURAL)
>> PLAN(B B NATURAL)
>>
>> i get error "dynamic sql error sql error code = -104 Token unknown .. 
>> PLAN
>>
>> how can i store plan for this type of query???
>
> It is showing you the plans for each view in the query. When trying to 
> specify your own plan, you can only specify *one* as far as I know - for 
> your own query, not the underlying views.
>
> So likely this would be ok:
> select * from
> XXX B
> PLAN (B NATURAL)
>
> However, you really should not be specifying your own plans. In almost all 
> cases a query can be optimized simply by adjusting the structure or by 
> adding appropriate indexes. Using you own plans should be ab absolutely 
> last resort only.
>
> -- 
> Wayne Niddery - TeamB (www.teamb.com)
> Winwright, Inc. (www.winwright.ca)

yes but indexes have wrong calculation of selectivity
if i select something with foreign key
e.g. table have 10000 records and only 90 have value but rest is null
then selectivity is very bad - but almost queries look for this 90 not for 
null
and then plan are in most case NATURAL :(
i suppose that indexes should have two selectivity for "not null" and "with 
null"

now i create selectable stored procedure to fix my problems
views are bad becaouse of plans :/

Karol Bieniaszewski 
Technical Details
Message-ID: <4861d4f9$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4860e8bb$1@newsgroups.borland.com> <48612e73@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,5ab8d73ddeb2b166
X-Google-Attributes: gid114a0e,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Karol Bieniaszewski" <liviuslivius@poczta.onet.pl>
Newsgroups: borland.public.interbase.sql
References: <4860e8bb$1@newsgroups.borland.com> <48612e73@newsgroups.borland.com>
Subject: Re: Plan for query from VIEW problem .. dynamic sql error sql error code = -104 Token unknown .. PLAN
Date: Wed, 25 Jun 2008 07:18:01 +0200
Lines: 53
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 195.205.151.58
Message-ID: <4861d4f9$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1214371065 195.205.151.58 (24 Jun 2008 22:17:45 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail