Subject Re: How to get best plan for typical Order–Customer?
Author kokok_kokok
The optimal plan for
select sum(Orders.units) from Orders inner join Customers on
Orders.CustomerId=Customers.CustomerId
where Orders.OrderDate between `2007/1/1' and `2007/12/31'
is:


PLAN JOIN (CUSTOMERS INDEX (IDX_ORDERS_DATE), CUSTOMERS INDEX
(RDB$PRIMARY8))



The suboptimal plan for
select sum(Orders.units) from Orders inner join Customers on
Orders.CustomerId=Customers.CustomerId
where Orders.OrderDate between `2007/1/1' and `2007/12/31'
and Customers.EntryDate between `2006/1/1' and `2006/12/31'
and Customers.CustomerType=1
is:


PLAN JOIN (CUSTOMERS NATURAL, ORDERS INDEX (FK_CUSTOMERID,
IDX_ORDER_DATE))

IDX_ORDER_DATE: Order date of Orders table
FK_CUSTOMERID: CustomerID in Orders table.



Thanks