且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么这么慢地在Linq中使用Skip方法对带有SQLite的实体

更新时间:2023-02-24 14:57:43

你好,亲爱的
我在SQL Server和VS 2010中创建表类",我从class创建了一个实体,从该实体生成的代码就像您生成的代码
下方是不同的

Hello Dear
I Create table ''class'' in SQL server and in VS 2010 I create an entity from class , code which was generated from that entity was like your generated code
just below was different

public ObjectSet<Class> Class
{
    get
    {
        if ((_Class == null))
        {
            _Class = base.CreateObjectSet<Class>("Class");
        }
        return _Class;
    }
}
private ObjectSet<Class> _Class;



而不是ObjectQuery< Class>我的VS生成ObjectSet< Class>

我更改了一些代码,而不是插入10000条记录,而是插入了20000条记录并运行程序,我看到的结果从来都不像你看到的那样
这是结果:



instead of ObjectQuery<Class> my VS generate ObjectSet<Class>

I change a little your code and instead of inserting 10000 record I insert 20000 record and run program , result which i saw was never like what you saw
this is result :

Time elapsed of query without Skip() method:
00:00:00.0724459
00:00:00.0153574
00:00:00.0155165
00:00:00.0292526
00:00:00.0151775
00:00:00.0639635
00:00:00.0153134
00:00:00.0154977
00:00:00.0150147
00:00:00.0167784
00:00:00.0399328
00:00:00.0214512
00:00:00.0150444
00:00:00.0153898
00:00:00.0148485
00:00:00.0158250
00:00:00.0159237
00:00:00.0156329
00:00:00.0153042
00:00:00.0148778
Time elapsed of  query with Skip() method:
00:00:00.0175573
00:00:00.0308169
00:00:00.0195496
00:00:00.0296008
00:00:00.0230691
00:00:00.0242020
00:00:00.0280368
00:00:00.0261236
00:00:00.0273193
00:00:00.0288516
00:00:00.0295745
00:00:00.0315337
00:00:00.0327198
00:00:00.0330120
00:00:00.0381269
00:00:00.0360055
00:00:00.0399509
00:00:00.0378671
00:00:00.0385484
00:00:00.0415859



每两个查询的时间少于1秒

我一次又一次地运行程序,但是结果差不多了.也许是因为我使用了.NET Framework 4,或者是因为我使用了Sql Server 2008 Management Studio,所以我建议您更改应用程序并再次运行它.



time consuming in each two query was smaller than 1 seconds

I run program again and again but result was almost that . perhaps it is because I use .NET framework 4 or because i use Sql Server 2008 Management Studio , I suggess you change your application setting a run it again