简体   繁体   English

实体框架查询性能慢

[英]Entity framework Slow query performance

I am using Entity framework 6.2.0 with WebAPI hosted on azure app service. 我正在将Entity Framework 6.2.0与WebAPI托管在azure应用程序服务上。

My database is not big with only two tables and I have a simple select query 我的数据库并不大,只有两个表,而且我有一个简单的选择查询

Account account =  Db.Accounts.Where(p => p.Code == Code && p.PersonId == 
PersonId).Include("Options").FirstOrDefaultAsync();

What i am struggling with is, when I deploy this on azure. 我正在苦苦挣扎的是,当我将其部署在天蓝色时。 and whenever i make the first call to the api which uses above query or when there is a significant gap of few minutes or 1 hour between two calls, Above process takes a long time to complete .almost 20-25 seconds, The next call is in less than a second. 每当我第一次调用使用上述查询的api或两次调用之间有几分钟或一小时的明显间隔时,上述过程需要很长时间才能完成。几乎需要20-25秒,下一次调用是在不到一秒钟的时间内

I have confirmed, that it's definitely not my network latency or something else that is slowing this down. 我已经确认,这绝对不是我的网络延迟或其他导致速度下降的原因。

Does anyone have a clue what I can look at? 有人知道我能看到什么吗?

My entity framework implementation is database-first. 我的实体框架实现是数据库优先的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM