Subject | Slow left join with stored procedure |
---|---|
Author | davissammybr |
Post date | 2010-08-07T19:33:22Z |
I have two tables. One contains a list of orders and other items with each order. I created a stored procedure that returns me the total value of items per order number and the key field (orderno), the order number. To return all order data and total items use this:
Select
Ordl.OrderNo,
Ordl.ClientName,
Ordl.Age,
Itens.TotalValue
from
OrderList Ordl
left join ( Select OrderNo, TotalValue from MyStoredProcedure ) Itens
on ( Itens.OrderNo=Ordl.OrderNo )
This is very slow. I don't know if I do something wrong.
How to improve performance?
Thanks.
Select
Ordl.OrderNo,
Ordl.ClientName,
Ordl.Age,
Itens.TotalValue
from
OrderList Ordl
left join ( Select OrderNo, TotalValue from MyStoredProcedure ) Itens
on ( Itens.OrderNo=Ordl.OrderNo )
This is very slow. I don't know if I do something wrong.
How to improve performance?
Thanks.