Subject | Re: [firebird-support] How to retrieve execution plan? |
---|---|
Author | Jakub Hegenbart |
Post date | 2004-02-15T15:50:13Z |
V So, 14. 02. 2004 v 18:19, harri007et p����e:
1) How did you come up with the idea that PLAN NATURAL = bad plan? Have
you ever tried to access 80% records of a 1gig table with indexed
access?
2) What are you trying to achieve with "Try again?" There's no "if
(rand()>0.9) then slow_things_down_and_go_natural();." This is Firebird,
not Windows :)
You should either recomupute index statistics (which _could_ improve the
situation if the data has drastically changed...)...
...or take a look at your data model, think about the query a bit, look
at some numbers (idx selectivities, row counts, expected percentage of
rows selected) and try to optimize it with hand (Hint! Hint! Planalyzer
http://delphi.weblogs.com/IBPLANalyzer :)...
...or - in some special cases - itmay be more efficient to employ some
SPs and cursors (and maybe even The One Mysterious Hidden Column...but
that's possibly an offshot, try optimizing the query first.)
I also once believed in The Almighty God of Indices, but hey, i was a
kid back then :)
Jakub Hegenbart
> Hi!Excuse me, but...
>
> Using delphi7+fibplus5+firebird.
>
> Is the following pseudo-code possible with the current api?
> ---
> assign query text;
> prepare/retreive execution plan;
> if WordCount('NATURAL') inside plan <= 2 then
> execute query
> else
> error 'BAD query plan, try again';
> ---
>
> FB1 has PLANONLY option, but this is "isql only"
>
> regards,
> Harri
1) How did you come up with the idea that PLAN NATURAL = bad plan? Have
you ever tried to access 80% records of a 1gig table with indexed
access?
2) What are you trying to achieve with "Try again?" There's no "if
(rand()>0.9) then slow_things_down_and_go_natural();." This is Firebird,
not Windows :)
You should either recomupute index statistics (which _could_ improve the
situation if the data has drastically changed...)...
...or take a look at your data model, think about the query a bit, look
at some numbers (idx selectivities, row counts, expected percentage of
rows selected) and try to optimize it with hand (Hint! Hint! Planalyzer
http://delphi.weblogs.com/IBPLANalyzer :)...
...or - in some special cases - itmay be more efficient to employ some
SPs and cursors (and maybe even The One Mysterious Hidden Column...but
that's possibly an offshot, try optimizing the query first.)
I also once believed in The Almighty God of Indices, but hey, i was a
kid back then :)
Jakub Hegenbart