Subject | Re: How to get best plan for typical Order–Customer? |
---|---|
Author | kokok_kokok |
Post date | 2008-11-15T15:09:23Z |
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
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