Subject | Re: [firebird-support] About warnings when submitting SPs... |
---|---|
Author | Alexandre Benson Smith |
Post date | 2004-07-01T21:37:10Z |
Rasmus Olesen wrote:
It's just a hint given by Marathon. If you create the same procedure in
ISQL you will ot get any warning.
and for unique constraints). But FB could just use descending indices
for MAX function, ascending indices will be good form MIN, but useless
for MAX.
You have two options:
1.) Create your PK using a DESCENDING index
2.) leave the axcending index created automatically by your PK
constraint and create another index on the same column as descending.
I would go the option 1
waht your query will do and think if will be good to have an index to
speed it up or not, sometimes (if the table was small enough), than the
speed diference should not be noted. And have a lot of indices could
confuse the optmizer in complex queries.
the index and see how it performs, look on the generated plan for the
both cases, indices could improve the select speed but will slowdown the
insert/update. One should take this into consideration.
Make your tests with more realistic data you can, you can't expect the
same plan/speed when you run your query with very different data.
Indices are good, but useless indices are bad, very bad !
--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br
>HiHi Rasmus,
>
>When i submit some SPs i get these strange plan-warnings, f.x. :
>
>INFO: Warning: SubOptimal Query Line 6 Column 7 - May not use Index
>(PLAN (T_ENTRIES NATURAL))
>
>
It's just a hint given by Marathon. If you create the same procedure in
ISQL you will ot get any warning.
>on this example :When you create a PK, an index is automatically created (the same for FK
>
>CREATE PROCEDURE A
>returns (
>maxtid int)
>AS
>begin
>select max(tid) from T_ENTRIES into :maxtid;
>end
>
>..and it seems to be because the 'tid' is a primary key in the
>table. It also happenes with a foreign key though, and even
>though i haven't explicitly defined any indicies anywhere in the
>entire db.
>
>(1.1) I'm guessing that defining a primary key, makes FB1.5(which
>i'm using btw.) implicitly defines an automatic index on the same
>column, at least thats what Marathon 3 told me...but is that the
>case ??
>
>
>
and for unique constraints). But FB could just use descending indices
for MAX function, ascending indices will be good form MIN, but useless
for MAX.
You have two options:
1.) Create your PK using a DESCENDING index
2.) leave the axcending index created automatically by your PK
constraint and create another index on the same column as descending.
I would go the option 1
>(1.2) Why is this warning coming up ?Just a hint.
>
>
>(1.2.1) Because it might execute slower than it optimally can ?yes.
>(=Performance warning)
>
>
>(1.2.2) Because it might execute a give a wrong answer ?no.
>(=Correctness warning)
>
>
>
>(1.3) How can i modified these SPs of this form that gives this kindCreate an index, but is not always the sollution, you should understand
>of warnings ??
>
>
>
waht your query will do and think if will be good to have an index to
speed it up or not, sometimes (if the table was small enough), than the
speed diference should not be noted. And have a lot of indices could
confuse the optmizer in complex queries.
>(1.4) Should one always change a SPs just because a compilationno... should be a case by case analyzes.
>generates a warning or are some of them conceptual and therefore
>execution-wise irrelevant ?
>
>
>(2) What are the professional guidelines for indicies anyway, whenYou should see how your query is execute without the index, then create
>SHOULDN'T they(should = faster searches, got that part) be used in a
>table ?
>
>
>
the index and see how it performs, look on the generated plan for the
both cases, indices could improve the select speed but will slowdown the
insert/update. One should take this into consideration.
Make your tests with more realistic data you can, you can't expect the
same plan/speed when you run your query with very different data.
Indices are good, but useless indices are bad, very bad !
>tia.see you !
>/Rasmus Olesen
>
>
--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br