我有一个查询,目的是查找表 item_location 中的记录,而表 operation_detail 中不存在一年中特定月份的记录
SELECT il.item_id,
il.SEQUENCE,
SUM (il.quantity) AS quantity,
i.buy_price,
i.sell_price, i.item_name, i.unit_measure_id,
i.is_raw_item AS is_raw
FROM item_location il, item i
WHERE il.quantity <> 0
AND il.item_id = i.item_id
AND il.SEQUENCE = i.SEQUENCE
AND NOT EXISTS (
SELECT od.*
FROM operation_detail od, operation_header oh, rt_operation o
WHERE od.item_id = il.item_id
AND od.SEQUENCE = il.SEQUENCE
AND od.operation_header_id = oh.operation_header_id
AND oh.operation_type_id = o.operation_type_id
AND o.operation_stock IN ('I', 'O')
AND MONTH (oh.operation_date) = @MONTH
AND YEAR (oh.operation_date) = @YEAR)
GROUP BY il.item_id,
il.SEQUENCE,
i.buy_price,
i.sell_price,
i.item_name,
i.unit_measure_id,
i.is_raw_item
请注意,使用给定超时从.net
平台运行此查询,从 SQL 运行它需要 40 秒DataAdapter
我的主要问题是 TimeOut....任何建议