我们有20个仓库和3.000件物品。因此,精确在线的ItemWarehouses表中有60.000行。但是,每60行检索需要1200 ms,因此仓库分析对此数据卷的总查询时间为3-4小时。
我试图限制使用以下筛选器检索的数据数量,因为我们只在具有一些非零库存信息的项中:
select t.*
from exactonlinerest..itemwarehouses t
where ( currentstock != 0 or projectedstock != 0 or plannedstockin != 0 or plannedstockout != 0 or safetystock != 0 or reorderpoint != 0)但是它仍然下载所有60.000种组合,并在PC上过滤它们。最终的结果是大约700个有效的仓库和商品库存信息组合。
是否有一种以更高性能检索数据的方法?
发布于 2017-06-07 09:03:51
Invantive SQL不将OR-构造转发到服务器端.但在这种情况下,您可能希望将OR更改为UNION (没有全部):
select t.*
from exactonlinerest..itemwarehouses t
where currentstock != 0
union
select t.*
from exactonlinerest..itemwarehouses t
where projectedstock != 0
union
select t.*
from exactonlinerest..itemwarehouses t
where plannedstockin != 0
union
select t.*
from exactonlinerest..itemwarehouses t
where plannedstockin != 0
union
select t.*
from exactonlinerest..itemwarehouses t
where safetystock != 0
union
select t.*
from exactonlinerest..itemwarehouses t
where reorderpoint != 0这些过滤器是转发到精确的在线,应该运行非常快,鉴于您的数据分布。UNION确保您只返回唯一的行。
https://stackoverflow.com/questions/44408114
复制相似问题