mssql-docker icon indicating copy to clipboard operation
mssql-docker copied to clipboard

Slow performance when using ODBC driver with SQL Server Linux

Open dhartl-rms opened this issue 4 years ago • 1 comments

We are exploring the use of SQL Server on Kubernetes for some of our workloads. However, when running our performance tests of a legacy C++ app which uses an ODBC driver, we are seeing severe performance degradation.

After some digging, I found that the ODBC driver appears to be calling an internal sproc sys.sp_columns_100 quite frequently. This sproc is significantly slower on Linux compared to the Windows version.

For a repro, I have setup two equally equipped VMs in Azure. One with SQL Server in Docker on Linux vs a Windows installation.

I’m able to repro (what I think is the issue) quite reliably by following these steps:

Setup

CREATE DATABASE foo
GO
USE foo
GO
CREATE TABLE bar (a INT, b INT)
GO

Run

DECLARE @cnt INT = 0;
WHILE @cnt < 20
BEGIN
   exec sp_columns_100 @table_name = 'bar'
   SET @cnt = @cnt + 1;
END;

Verify

select @@version
select  last_worker_time, total_worker_time / execution_count as 'avg worker time', execution_count
FROM sys.dm_exec_procedure_stats pt 
where OBJECT_NAME(pt.object_id) = 'sp_columns_100'

Output on Windows VM

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Microsoft SQL Server 2019 (RTM) - 15.0.2000.5 (X64) 
	Sep 24 2019 13:48:23 
	Copyright (C) 2019 Microsoft Corporation
	Developer Edition (64-bit) on Windows Server 2019 Datacenter 10.0 <X64> (Build 17763: ) (Hypervisor)


last_worker_time     avg worker time      execution_count
-------------------- -------------------- --------------------
402                  946                  20

Output on Linux VM (inside docker container)

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Microsoft SQL Server 2019 (RTM-CU12) (KB5004524) - 15.0.4153.1 (X64)
        Jul 19 2021 15:37:34
        Copyright (C) 2019 Microsoft Corporation
        Developer Edition (64-bit) on Linux (Ubuntu 20.04.2 LTS) <X64>

last_worker_time     avg worker time      execution_count
-------------------- -------------------- --------------------
                3084                 3305                   20

It seems odd that the execution time of this sproc is so different. Is there a way to configure SQL Server on Linux behave the same way as the Windows counterpart?

dhartl-rms avatar Sep 01 '21 17:09 dhartl-rms

can you please open a support ticket with CSS ( Microsoft support) to ensure you get fast and effective support on this.

amvin87-zz avatar Sep 01 '21 17:09 amvin87-zz