Subject Re: optimizing query
Author james_027
hi Svein, Iam having problem reading the plan sort. Here is my very
slow query I want to work on it.

select m."customerid",
m."invdate", d."invid", d."invno", d."invdetailsid",
d."item", d."qty", d."m3", d."rate", d."otherqty",
d."qty2", d."m32", d."rate2", d."otherqty2",d."priceby",
d."priceby2", d."lacking",
d."adjustment", d."discount", d."discount2", d."losses",
d."damage", d2."etd", d2."port",
d."drqty", d."packingid",
from "invoicedetails" d inner join "invoice" m on m."invid" =
left join "packing" d2 on d."packingid" =

the plan sort is this ...


here are my indexes

"invoicedetails": IDX1(packingid, invdetailsid), IDX2(invid), IDX3
"invoice": primarykey("invid"), IDX1("invdate","customer")
"packing": primarykey("packingid"), IDX1("etd","containerno")

Iam new in reading the plan sort, what is na meaning of NATURAL?

I also read on your conversation between you and Edwin. You suggest
that ... for example if I have a Status field or Invoice Date field
and I have index it because what the IB manual says that if your
performing a search in a field or you often used that field in your
where clause you have to index it to perform fast searching, then you
say that for example my status field only has 3 possible values so it
is better if I drop that index?

As you saw I have the IDX1 in invoice and IDX1 in packing which has
two fields, thats because I have some operation where both two field
where always use and the same time. Could my search be optimize have
these index?