Skip to main content
Copy edit
Source Link
Paul White
  • 90.3k
  • 30
  • 424
  • 663

SQL Compilation\sec Compilations/sec high when load testing a simple procedure

I tryam trying to load test a simple insert stored procedure:

CREATE TABLE _test(ID BIGINT)
GO
CREATE OR alterALTER PROCEDURE dbo.test_sp
AS
BEGIN
    SET NOCOUNT ON;
    BEGIN
        INSERT INTO _test
        SELECT CAST(RAND() * 10000 AS BIGINT)
    END
END

Not whenWhen I runexecute this spstored procedure with SQLStressthe SQL Stress tool, I get SQL Compilation\secSQL Compilations/sec equal to Batch Request\sec.

Interesting fact is thatBatch Requests/sec. Interestingly, SQL Re-Compilations\secSQL Re-Compilations/sec is 0zero.   

Perf counters

Both optimized for ad-hocoptimize for ad-hoc workloads and Forced parametrizationforced parameterization are enabled. The same picture is the same even if I change my spprocedure to a simple SELECT 1. Any help will be appreciated. I use

I am using Microsoft SQL Server 2016 (SP3) (KB5003279).

A profiler trace shows the tool sends a simple EXEC dbo.test_sp

SQL Compilation\sec

I try to load test a simple insert stored procedure

CREATE TABLE _test(ID BIGINT)

CREATE OR alter PROCEDURE dbo.test_sp
AS
BEGIN
    SET NOCOUNT ON;
    BEGIN
        INSERT INTO _test
        SELECT CAST(RAND() * 10000 AS BIGINT)
    END
END

Not when I run this sp with SQLStress tool I get SQL Compilation\sec equal to Batch Request\sec.

Interesting fact is that SQL Re-Compilations\sec is 0.  Perf counters

Both optimized for ad-hoc and Forced parametrization are enabled. The same picture is even if I change my sp to a simple SELECT 1. Any help will be appreciated. I use Microsoft SQL Server 2016 (SP3) (KB5003279).

Compilations/sec high when load testing a simple procedure

I am trying to load test a simple insert stored procedure:

CREATE TABLE _test(ID BIGINT)
GO
CREATE OR ALTER PROCEDURE dbo.test_sp
AS
BEGIN
    SET NOCOUNT ON;
    BEGIN
        INSERT INTO _test
        SELECT CAST(RAND() * 10000 AS BIGINT)
    END
END

When I execute this stored procedure with the SQL Stress tool, I get SQL Compilations/sec equal to Batch Requests/sec. Interestingly, SQL Re-Compilations/sec is zero. 

Perf counters

Both optimize for ad-hoc workloads and forced parameterization are enabled. The picture is the same even if I change my procedure to a simple SELECT 1.

I am using Microsoft SQL Server 2016 (SP3) (KB5003279).

A profiler trace shows the tool sends a simple EXEC dbo.test_sp

Became Hot Network Question
Source Link

SQL Compilation\sec

I try to load test a simple insert stored procedure

CREATE TABLE _test(ID BIGINT)

CREATE OR alter PROCEDURE dbo.test_sp
AS
BEGIN
    SET NOCOUNT ON;
    BEGIN
        INSERT INTO _test
        SELECT CAST(RAND() * 10000 AS BIGINT)
    END
END

Not when I run this sp with SQLStress tool I get SQL Compilation\sec equal to Batch Request\sec.

Interesting fact is that SQL Re-Compilations\sec is 0. Perf counters

Both optimized for ad-hoc and Forced parametrization are enabled. The same picture is even if I change my sp to a simple SELECT 1. Any help will be appreciated. I use Microsoft SQL Server 2016 (SP3) (KB5003279).