Paging time costs

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
msimko
Posts: 9
Joined: Thu 06 Feb 2014 09:40

Paging time costs

Post by msimko » Tue 29 Jul 2014 16:06

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.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Paging time costs

Post by MariiaI » Wed 30 Jul 2014 13:35

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

msimko
Posts: 9
Joined: Thu 06 Feb 2014 09:40

Re: Paging time costs

Post by msimko » Wed 06 Aug 2014 10:50

I've sent an email with sample project to [email protected]
Could you please have a look at it?

Thanks.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Paging time costs

Post by MariiaI » Wed 06 Aug 2014 11:35

We have contacted you by e-mail.

msimko
Posts: 9
Joined: Thu 06 Feb 2014 09:40

Re: Paging time costs

Post by msimko » Wed 06 Aug 2014 12:41

Thank you for your help.
The issue is related with PostgreSQL server, not LinqConnect.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Paging time costs

Post by MariiaI » Wed 06 Aug 2014 13:00

If you have any further questions regarding working with LinqConnect, feel free to contact us.

Post Reply