我使用實體框架使用.skip
和.take
實施分頁。這工作正常,但是當我獲取10萬條記錄的數據庫中的記錄數(對於網格頁碼而言UIClient需要計數)時,它佔用大量時間,大約600毫秒,這是很大的。使用實體框架進行分頁時的性能問題
如果我不使用計數只有尋呼實現,那麼它幾乎需要20到25毫秒。如何進行高效計數?我如何從600毫秒降低到50毫秒左右?我用
示例查詢:
int count = (from c in dbcontext.Customer
where c.customerName ='xyz' && c.date >= 'dateTime'
select c.CustomerId).Count();
我有索引上Name
,dateTime
和CustomerId
是主鍵。
由於提前,
阿希奈
這是''dateTime''值的佔位符?什麼是'c.date'屬性的類型? – rcdmk