3表sql查询需要40多秒

时间:2017-04-27 14:31:15

标签: sql sql-server performance time view

我们有3个不同的表格;

  **line_item_table;**  
  item_id, description, qtty, price-

  **supplier_offer_table**  
suplier_id, suplier_name , item_id , suplier_price

**warehouse_info_table**  
item_id, in_out_info(0/1),quantity, price, warehouse_id(1 or 2) 

我正在尝试使用来自这3个表的信息创建一个视图;

**view**   
item_id, 
line_item_table.description, 
line_item_table.qtty, 
line_item_table.price, 
(warehouse id = 1 item quantity (in-out quatntity ) from warehouse_info_table), 
(warehouse id = 1 last price for that item_id from warehouse_info_table) , 
(warehouse id = 2 item quantity (in-out quatntity ) from warehouse_info_table), 
(warehouse id = 2 last price for that item_id  from warehouse_info_table),
(lowest price and supplier_name for that item_id from supplier_offer_table ) ,
(second lowest price and supplier_name for that item_id from supplier_offer_table ) ,
(third lowest price and supplier_name for that item_id from supplier_offer_table )

对于240个订单项,大约需要40秒才能减少时间吗?

0 个答案:

没有答案