最近转到EFCore做项目,发现了一个坑,在项目上线后发现随着数据增加查询速度越来越慢,发现原来是进行了全表查询
原来的查询
var orderCollect = (
from a
in ctx.ECQD_ORDER_HEAD
where a.ID ==
new
Guid
(id)
orderby a.ORDER_ID
select a);
修改后
var orderId =
new
Guid(id);
var orderCollect = (
from a
in ctx.ECQD_ORDER_HEAD
where a.ID == orderId
orderby a.ORDER_ID
select a);