r/SQLServer • u/daler86 • May 15 '26
Question SQL Server query much slower on VMware VM compared to physical server (same DB, same workload)
I have a SQL Server database running on two environments:
- Physical server (Intel Xeon E5-2420, 48 GB RAM, HDD RAID)
- VMware ESXi VM (Intel Xeon E5-2620, 4 cores, 96 GB RAM, SSD datastore)
The same query runs significantly faster on the physical server (~45 seconds) but is slower on the VM (~85+ seconds), even though the VM has better hardware.
4
Upvotes
•
u/AutoModerator May 15 '26
After your question has been solved /u/daler86, please reply to the helpful user's comment with the phrase "Solution verified".
This will not only award a point to the contributor for their assistance but also update the post's flair to "Solved".
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
7
u/phildude99 1 May 15 '26
My experience has been that disk configuration can play a major role.
On a physical server, storage of OS, data, and log files are usually physically 3 drives, but often in a VM config the 3 logical drives often point to a single physical drive resulting in more contention and reduced throughput.
6
u/SnooCalculations1882 May 15 '26
Just a small slip I've seen alot, double check the disk allocation unit size, ensure your log, data and temp are formatted 64k ntfs
5
u/Afraid_Baseball_3962 May 15 '26
Check the vCPU in your VM. Do you have one CPU with eight cores (for example) or eight CPUs with a single core each? It can make a huge difference for multi-threaded processes. Fewer CPUs with higher core counts work better, apparently (I hadn't expected a difference). Also, on physical hardware, you're not sharing resources but on virtual hardware, you can end up competing with other VMs on the host. Is the host over-provisioned?
4
u/Flashylotz May 15 '26
Your physical server has six cores and 12 threads, while your VM is limited to 4 cores, so effectively only 4 threads.
You are giving it 1/3 of the cpu.
If your query is CPU bound than it would make a difference.
3
u/jdanton14 Microsoft MVP May 15 '26
Which disk drivers are you using in VMware? Can you confirm that memory is reserved and not overcommitted?
Like everyone else said first confirm that you have the same execution plan and then try to get a better understanding of the physical infrastructure. You may also see differing wait stats in a virtual environment
2
u/SingingTrainLover May 15 '26
Is VMware configured so it doesn't steal CPU cycles from what it perceives as an 'idle' machine? Ballooning can absolutely kill performance of SQL Server on a VM.
Edit to add a same concern about memory. SQL Server needs ALL the memory ALL the time. Any time the host takes memory away, you're going to lose performance.
2
u/mqaiser May 16 '26
Power Management Recommendations
This is extremely important.
ESXi Host BIOS + Power Policy
Set server BIOS and ESXi host to:
Avoid:
Reason: SQL Server is latency-sensitive. CPU frequency scaling causes query latency spikes.
2
u/mqaiser May 16 '26
SQL Server is often storage-bound.
Use:
Separate disks ideally for:
2
u/Sov1245 May 15 '26
It would be crazy if the HDD -> SSD change alone didn't vastly overshadow the very minor VM overhead.
But yes, check the query plan before/after to make sure you're really looking at apples to apples.
9
u/VladDBA Microsoft MVP May 15 '26
Have you compared the execution plans and the output of stats IO?
How do the instances' configuration look like (maxdop, CTP, Max memory)?
1
u/SirGreybush 1 May 15 '26
How is the SSD shared, if, you configured the advanced settings the same? (as per other comments)
A SAN is much slower than a SCSI direct parallel interface but has the benefit of being shared for multiple VMs. If the SSDs are local on-prem on your hardware, are they Raid-1 over SATA-2? If so, a Raid-5 or Raid-10 would be better.
To compensate lowered/shared disk IO, assign more RAM to that VM, and allocate Total - 3g for exclusive SQL Server. Never allocate 100% to SQL Server.
If you run SSIS and/or SSRS then allocate even less dedicated RAM to SQL Server to allow these services to have suffient RAM to run well and prevent memory swapping to disk. I'd keep 3g for OS, 1g per "service" that server is running (SSIS/SSRS/any website).
Also 4 cores isn't much horsepower. More cores would help but that increases per-server core licensing costs. It's more worthwhile doubling the RAM than doubling the cpu cores, money-wise.
1
u/mods_are_morons May 17 '26
Had the same issue at a previous job. The problem was the networking for vmware esx was being saturated by all the virtual systems that were running. Since the virtual drives were going over the same network as everything else, the queries and responses had to wait their turn. Which happened constantly.
3
u/JamesRandell May 15 '26
May be a daft suggestion, is there a virtual cpu presentation option or cpu compatibility mask? If so, pick host so it doesn’t use a different instruction set
2
u/FunkRobocop May 15 '26
Did you install the vmware guest driver? Or is that no longer required on modern os?
2
u/mqaiser May 16 '26
SQL Server Max Memory
Inside Windows/SQL: Do not give all memory to SQL Server.
Leave RAM for:
1
u/Lost_Term_8080 May 15 '26
you gave your physical server 6 physical cores with hyperthreading and gave your VM 4 virtual cores
1
u/CPDRAGMEISH May 15 '26
IT'SG OK
Update Statistics ?
-
Edition of SQL Server is similar. Updates ?
1
u/Ancient-Box1652 May 15 '26
Disable VBS virtualisation based security and untick IOMMU on the CPU for the VM
1
u/thepotplants May 15 '26
What else is happening on the host? Is it over provisioned? Noisy neighbours? Miss matched neighbours?
Are your disks attached directly? SAN/NAS? (I've seen VMs run off a USB drive).
If possible, move everything else off the host so your VM has exclusive access and test again. (To rule out resource contention)
1
u/mqaiser May 16 '26
For running Microsoft SQL Server on VMware, the key recommendations are usually around:
1
u/mqaiser May 16 '26
Inside Windows guest OS:
Set:
Avoid:
1
u/CPDRAGMEISH May 16 '26 edited May 16 '26
IT'SG OK
STATISTICS IO
Check logical reads on these 2 servers.
If both servers hve similar logical reds
then the cause is the differences between machines./SQL Instances
1
u/CPDRAGMEISH May 16 '26
IT'SG OK
1
u/Anxious-Condition630 May 18 '26
Isnt this under the "Obvious" category? VM has overhead...also Server might not have VM optimization enable,