Page 1 of 1

Paging time costs

Posted: Tue 29 Jul 2014 16:06
by msimko
Hello,

I have a question regarding paging using linq concept.

I use the following way to fetch data:

Code: Select all

public List ListPage(int pageSize, int page)
{
    return dataCtx.SomeTable.Skip(page * pageSize).Take(pageSize).ToList();
}
I've executed some performance tests

Code: Select all

for (int i = 0; i < 1000; i++)
{
    service.ListPage(100, i);
}
and

Code: Select all

for (int i = 0; i < 1000; i++)
{
    service.ListPage(100, 1000 - i);
}
I was surprised, that time consumption of these two tests was not same. First test takes much more time then the second one.
After investigation, one for-loop cycle in the second test takes approximately the same time, regardless the value of variable 'i' (bit less for large values of 'i').
But this is not true for the first test. One for-loop cycle for small values of 'i' takes same time as in the second case. But when 'i' grows, elapsed time for one for-loop cycle grows as well. For large values of 'i', it takes the same time as to fetch all data from the table.
Moreover, if I change the range for 'i' in the first test to

Code: Select all

for (int i = 100; i < 1000; i++)
, then the time for one loop is constant and small (as expected).

How can I ensure the same time consumption of one for-loop cycle in the first test when 'i' is in the range

Code: Select all

for (int i = 0; i < 1000; i++)
?

Thank you for reply.

Re: Paging time costs

Posted: Wed 30 Jul 2014 13:35
by MariiaI
First test takes much more time then the second one.
Basically, the first initialization of DataContext could take some time to perform due to the fact that it should get each type in the model.
Also, if both tests are performed in one application, one after another and both use one instance of DataContext, in the second case materialization will not be performed - entities will be taken from the cache.

If possible, provide us with a complete sample project with your LinqConnect model, so that we are able to investigate the performance issue and find the solution for you.

Please refer to
http://www.devart.com/linqconnect/docs/ ... mance.html
http://www.devart.com/linqconnect/docs/ ... ntity.html

Re: Paging time costs

Posted: Wed 06 Aug 2014 10:50
by msimko
I've sent an email with sample project to [email protected]
Could you please have a look at it?

Thanks.

Re: Paging time costs

Posted: Wed 06 Aug 2014 11:35
by MariiaI
We have contacted you by e-mail.

Re: Paging time costs

Posted: Wed 06 Aug 2014 12:41
by msimko
Thank you for your help.
The issue is related with PostgreSQL server, not LinqConnect.

Re: Paging time costs

Posted: Wed 06 Aug 2014 13:00
by MariiaI
If you have any further questions regarding working with LinqConnect, feel free to contact us.