I implemented paging using Entity Framework using .skip
and .take
. This works fine, but when I fetch the count of number of records in the database for 10 lakhs records (count is required for UIClient for grid page numbers) it is taking lot of time, around 600 ms which is huge.
If I don't use the count only the paging is implemented then it is taking hardly 20 to 25 ms. How to make efficient count? How can I bring down from 600 ms to say around 50 ms?
sample query that I used:
int count = (from c in dbcontext.Customer
where c.customerName ='xyz' && c.date >= 'dateTime'
select c.CustomerId).Count();
I have index on Name
, dateTime
and CustomerId
is the primary key.
Thanks in advance,
Abhinay
'dateTime'
value a placeholder? What is the type ofc.date
property?