通过 Tedious 调用一个简单的存储过程需要这么长时间是有原因的吗?

Is there a reason a call to a simple stored procedure via Tedious is taking so long?

我注意到,当调用一个简单的存储过程 CreateStatusReport 时,它只是将 INSERT 插入到 table,它通常需要异常长的时间来执行,我就是这样(无论好坏) 假设与一些 TDS 开销或我调用它的方式有关。

这是在 Node.js REST API 中调用的 TDS 代码:

function createReport(req, res) {
    let isReleased = false;

    let connection = new Connection(config);  

    connection.on('connect', function(err) {  
        let sql = "CreateStatusReport";

        if (err) console.log("**CN-ERROR", err);

        let request = new Request(sql, (err)=>{
            if (err) {
                console.log("**RQ-ERROR**", err);
            }
        });

        // Check to see if user clicked the "Release" button...
        if (typeof req.body.release != 'undefined')
            isReleased = true;

        request.addParameter('empid', TYPES.NVarChar, req.body.empid);
        request.addParameter('userid', TYPES.NChar, req.body.userid);
        request.addParameter('firstname', TYPES.NVarChar, req.body.fname);
        request.addParameter('lastname', TYPES.NVarChar, req.body.lname);
        request.addParameter('title', TYPES.NVarChar, req.body.title);
        request.addParameter('cabinet', TYPES.NVarChar, req.body.cabinet);
        request.addParameter('office', TYPES.NVarChar, req.body.office);
        request.addParameter('division', TYPES.NVarChar, req.body.division);
        request.addParameter('branch', TYPES.NVarChar, req.body.branch);
        request.addParameter('perstart', TYPES.VarChar, req.body.periodStart);
        request.addParameter('perend', TYPES.VarChar, req.body.periodEnd);
        request.addParameter('status', TYPES.NVarChar, req.body.status);
        request.addParameter('needs', TYPES.NVarChar, req.body.needs);
        request.addParameter('goals', TYPES.NVarChar, req.body.goals);
        request.addParameter('concerns', TYPES.NVarChar, req.body.concerns);
        request.addParameter('released', TYPES.Bit, isReleased);

        connection.callProcedure(request);

        request.on("requestCompleted", ()=> {
            res.redirect("/kudos")    
        });
    });  
}

存储过程非常简单,所以我将 "guts" 放在这里:

INSERT INTO [status-report] (empid, [userid], firstname, lastname, title,[cabinet], [office], [division], [branch], [period-start], [period-end], [date-posted], [status], needs, goals, concerns, released) 
VALUES (@empid, @userid, @firstname, @lastname, @title, @cabinet, @office, @division, @branch, @perstart, @perend, GETDATE(), @status, @needs, @goals, @concerns, @released)

记录实际创建到系统中最多可能需要几秒钟,我不知道为什么,因为系统是在高性能生产系统上。

这里有没有我忽略的东西?关于如何找到根本原因有什么建议吗?

提前致谢!

更新

USE [kudos]
GO

/****** Object:  StoredProcedure [dbo].[GetList]    Script Date: 5/1/2019 4:39:50 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:      <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[GetList]
AS
BEGIN
    SET NOCOUNT ON

    SELECT 
        [id],
        [empid],
        [lastname] + ', ' + [firstname] AS [name],
        LTRIM(RTRIM([userid])) AS [userid],
        [title],
        [cabinet],
        [office],
        [division],
        [branch],
        CONVERT(nvarchar(10), [period-start], 110) AS [periodstart],
        CONVERT(nvarchar(10), [period-end], 110) AS [periodend], 
        CONVERT(nvarchar(10), [date-posted], 110) AS [dateposted],
        IIF(released = 1, 'Released', 'In Progress') AS [released]
    FROM 
        [status-report] 
    WHERE 
        [date-posted] BETWEEN GETDATE() - 21 AND GETDATE() 
    ORDER BY 
        [date-posted] DESC
END
GO

这是一个 ID10T 错误(我的)。生产中有负载均衡器。有时会拨打电话,有时不会,因为两个系统上的代码不同步。