My cloud-based server runs a SQL Server Query 50% slower after an upgrade to dual core from single core

扶醉桌前 提交于 2019-12-25 03:32:33

问题


My application runs SQL Server 2008 on Windows Server 2008 using Tomcat.

I am using a Cloud-based server

One of my queries takes exactly 48 seconds to run from the application. It pulls 425 records from the database.

I was not surprised by the length of time.

Although a similar query on Oracle ran in 6 seconds, the Oracle setup had 2GB of memory and a quad-processor, whereas my SQL Server set up was 1GB of memory and a single 2.66GHZ processor.

Therefore I increased my server spec to 2GB. There was no change.

I then increased my server spec to dual processor from single processor. I was surprised to find that the query now took longer - exactly 70 seconds!

I am aware that the conversion of the query from P/SQL to T/SQL may have been done in a very non-efficient way. And there may be speed differences between Oracle and SQL Server. However my main question is really, why should the same query now run slower on a dual-core system than on a single-core?

Thank you!


回答1:


Depending on the hypervisor used and the total load on the server, dual virtual CPUs can result in getting (significantly) less CPU time, as some hypervisor's scheduler insists of finding 2 CPUs that are schedulable at the same time. If your query is single-threaded, the advantage of a second CPU is zero, but getting less CPU time makes it slower.

Exactly the opposite direction is another possibility: If your query is multithreaded and your storage is slow, then the 2 threads can create a random IO storm, that decreases your storage throughput.



来源:https://stackoverflow.com/questions/8926005/my-cloud-based-server-runs-a-sql-server-query-50-slower-after-an-upgrade-to-dua

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!