EF 쿼리 웹 응용 프로그램을 통해 실행하는 일부 성능 측정 문제가 있고 Profiler를 실행하면 T-SQL이 SQL 쿼리 창으로 직접 생성되었습니다. 그것이 실행 주위 221'095 MS했다 것을 알 수엔티티 프레임 워크 및 SQL Server 프로필러
IEnumerable<application> _entityList = context.applications
.Include(context.indb_generalInfo.EntitySet.Name)
.Include(context.setup_budget.EntitySet.Name)
.Include(context.setup_committee.EntitySet.Name)
.Include(context.setup_fund.EntitySet.Name)
.Include(context.setup_appStatus.EntitySet.Name)
.Include(context.appSancAdvices.EntitySet.Name)
.Where(e => e.indb_generalInfo != null);
if (isIFL != null)
_entityList = _entityList.Where(e => e.app_isIFL == isIFL);
int _entityCount = _entityList.Count(); // hits the database server at this line
EF 쿼리 위를 추적하는 동안 SQL 프로파일 러 : 다음
은 웹 응용 프로그램을 통해 실행 내 EF의 쿼리입니다. (30,000+, 11,000+를 갖는 indb_generalInfo 및 30,000+ 레코드를 갖는 appSancAdvices를 갖는 애플리케이션 테이블).
그러나 Profiler에서 T-SQL을 복사하고 쿼리 창에서 직접 실행하면 4'000 ms 만 사용됩니다.
왜 그렇습니까?
동일한 쿼리를 여러 번 실행 해 보셨습니까? Entity Framework는 여전히 해당 쿼리를 생성해야하지만 이후 요청을 위해 캐시됩니다. 또한,'Count()'를하고 있다면, 열심히 로딩 할 필요가 없다. –
예 이전에 시도 했었습니다. 그러나 문제는 @Arnold가 정확히 알게 된 것이 었습니다. –