Windows Server 2008 R2上的LINQ To SQL Slow [英] LINQ To SQL Slow on Windows Server 2008 R2

查看:136
本文介绍了Windows Server 2008 R2上的LINQ To SQL Slow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

那里
我们只是将其中一个.Net应用程序从Windows 2003 Server迁移到了虚拟Windows Server 2008 R2(64Bit,VMWare).

此应用程序是运行在.Net Framework 4.0(32位)上的简单控制台应用程序,它运行不同的作业以选择,修改业务数据并将其保存到数据库.对于数据库,我们使用SQL 2008 R2.

由于我们在Windows Server 2008 R2上运行该应用程序,因此我们认识到,使用LINQ to SQL执行Select-Statement的速度比以前使用的Windows Server 2003慢.我们使用简单的LINQ查询进行了检查,在Win 2008上花费了大约500毫秒的时间.

我们使用System.Data.Linq.DataContext并使用方法GetTable< classxy>()从数据库中获取对象.
为了比较持续时间,我们花了从创建数据上下文到从应用程序中的DB对象返回到.Net对象的映射所花费的时间.
参见代码:

 System.Data.IDbConnection testConnection;
            System.Data.Linq.Mapping.MappingSource testMappingSource;
            ...
            ...
            使用(System.Data.Linq.DataContext dc =新的System.Data.Linq.DataContext(testConnection,testMappingSource))
            {
                dc.DeferredLoadingEnabled = false;

                返回 =(来自 dcObject dbObject  dc中的. GetTable< testtable>()
                          选择 dbObject).FirstOrDefault();
            }</testtable> 



在Windows 2008 R2 Server上,安装了.Net Framework 4.0,并且在服务器功能中启用了.Net Framework 3.5.1功能.

该应用程序已安装在三个Windows 2003 Server的三个不同阶段(开发,测试,生产)上.现在,它可以在三个虚拟Windows 2008 R2 Server上运行.我们在所有三个Windows 2008 R2 Server上都遇到相同的问题.我们甚至在物理Windows 2008 R2 Server上进行了测试;那里同样的问题.

有谁知道造成这种差异的原因吗?解决此问题的解决方案可能是什么?

在此先多谢!
问候
Tom

解决方案

根据我从您的描述中收集到的信息,如果现在这样的话,您正在虚拟机中运行测试. blockquote>

值得一看的地方是SQL Server分析器.检查两个客户"的陈述是否相同或是否有所不同.

如果两个客户端都生成相同的SQL语句,那么您还可以检查客户端设置.例如,如果您要获取大量数据,则应将网络数据包的大小修改为与2003服务器中的大小相同.


Hi There
We just moved one of our .Net applications from a Windows 2003 Server to a virtual Windows Server 2008 R2 (64Bit, VMWare).

This application is a simple console application running on .Net Framework 4.0, 32Bit, that runs different jobs to select, modify and save business data to a database. For the database we use SQL 2008 R2.

Since we run the application on the Windows Server 2008 R2 we recognized, that the execution of Select-Statements with LINQ to SQL are slower than on the Windows Server 2003 we used before. We checked it with a simple LINQ Query, and that tooks about 500 milliseconds longer on Win 2008.

We use the System.Data.Linq.DataContext and get Objects from the Database with the Method GetTable<classxy>().

To compare te duration we took the time from creating the datacontext until the mapping from the DB-Objects back to the .Net-Objects in the application.
See the code:

System.Data.IDbConnection testConnection;
            System.Data.Linq.Mapping.MappingSource testMappingSource;
            ...
            ...
            using (System.Data.Linq.DataContext dc = new System.Data.Linq.DataContext(testConnection, testMappingSource))
            {
                dc.DeferredLoadingEnabled = false;

                return  = (from dbObject in dc.GetTable<testtable>()
                          select dbObject).FirstOrDefault();
            }</testtable>



On the Windows 2008 R2 Server, the .Net Framework 4.0 is installed, and in the server features the .Net Framework 3.5.1 Features are enabled.

The application was installed on three different stages (Dev, Test, Production) on three Windows 2003 Server. Now it runs on three virtual Windows 2008 R2 Server. We have the same Problem on all three Windows 2008 R2 Server. And we even tested it on a physical Windows 2008 R2 Server; same Problem there.

Has anynone an idea what causes this difference? And what may be solution to resolve this problem?

Thanks a lot in advance!
Greets
Tom

解决方案

From what I gather from your description you are running your tests in a VM now, if this is the case a slower time is to be expected.


One place to look at is the SQL Server profiler. Check if the statement is the same from both ''clients'' or does it have differences.

If both clients generate the same SQL statement then you could also check client side settings. For example, if you''re fetching lot''s of data, the network packet size should possibly be modified to be the same as in the 2003 server.


这篇关于Windows Server 2008 R2上的LINQ To SQL Slow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆