SQL Server休眠非常慢的查询

时间:2019-04-02 18:26:00

标签: sql-server

我有一个选择视图,使用Microsoft SQL Server Management Studio可以在不到00:00:01的速度运行。但是,使用弹簧靴并进入休眠状态时,需要花费很长时间。

我已经创建了一个表格表单视图,并使用了休眠和弹簧状态,并且执行速度非常快。它看起来服务器在Management Studio和JDBC驱动程序上运行时会生成不同的执行计划,这只是一个猜测。

这是休眠状态的统计信息

Session Metrics {
42723 nanoseconds spent acquiring 1 JDBC connections;
0 nanoseconds spent releasing 0 JDBC connections;
909914 nanoseconds spent preparing 9 JDBC statements;
698262857581 nanoseconds spent executing 9 JDBC statements;
0 nanoseconds spent executing 0 JDBC batches;
0 nanoseconds spent performing 0 L2C puts;
0 nanoseconds spent performing 0 L2C hits;
0 nanoseconds spent performing 0 L2C misses;
0 nanoseconds spent executing 0 flushes (flushing a total of 0 entities and 0 collections);
3636 nanoseconds spent executing 1 partial-flushes (flushing a total of 0 entities and 0 collections)

我正在同一主机上运行spring boot应用程序和数据库服务器。因此,我认为这不是网络问题。我在生产Env上有相同的行为。和本地开发环境。

服务器活动显示了很多等待,如下所示:

TaskState   Command WaitTime_ms App WaitType    WaitResource    BlockBy
RUNNABLE    SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2aacd7b4080 WaitType=e_waitPipeGetRow nodeId=75    60
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2a285ce1880 WaitType=e_waitPipeGetRow nodeId=66    60
RUNNABLE    SELECT  0   Microsoft JDBC Driver for SQL Server            
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2a325e71400 WaitType=e_waitPipeNewRow nodeId=87    60
RUNNABLE    SELECT  0   Microsoft JDBC Driver for SQL Server            
RUNNING SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2aacd7b5800 WaitType=e_waitPipeNewRow nodeId=79    60
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server            
SUSPENDED   SELECT  22537   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Port2c8afdd4f00 WaitType=e_waitPortOpen nodeId=0   60
RUNNING SELECT  0   Microsoft JDBC Driver for SQL Server            
RUNNABLE    SELECT  0   Microsoft JDBC Driver for SQL Server            
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2aacd7b5800 WaitType=e_waitPipeNewRow nodeId=79    60
RUNNABLE    SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2a6e6f84080 WaitType=e_waitPipeNewRow nodeId=66    60
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server            
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server            
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2bec74a5800 WaitType=e_waitPipeNewRow nodeId=83    60
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2a325e70d80 WaitType=e_waitPipeNewRow nodeId=87    60
SUSPENDED   SELECT  38  Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2b98d69f600 WaitType=e_waitPipeGetRow nodeId=48    60
RUNNABLE    SELECT  0   Microsoft JDBC Driver for SQL Server            
RUNNABLE    SELECT  0   Microsoft JDBC Driver for SQL Server            
RUNNABLE    SELECT  0   Microsoft JDBC Driver for SQL Server            
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2a325e71400 WaitType=e_waitPipeNewRow nodeId=87    60
RUNNABLE    SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2aacd7b4480 WaitType=e_waitPipeGetRow nodeId=75    60
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2a285ce1c80 WaitType=e_waitPipeGetRow nodeId=66    60
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server            
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server            
RUNNABLE    SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2a6e6f84080 WaitType=e_waitPipeGetRow nodeId=66    60
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server            
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2bec74a4080 WaitType=e_waitPipeGetRow nodeId=79    60
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2aacd7b5900 WaitType=e_waitPipeNewRow nodeId=79    60
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server            
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server            
RUNNABLE    SELECT  0   Microsoft JDBC Driver for SQL Server            
RUNNABLE    SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2a285ce1a80 WaitType=e_waitPipeGetRow nodeId=66    60
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server            
RUNNING SELECT  0   Microsoft JDBC Driver for SQL Server            
SUSPENDED   SELECT  1   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2a325e71180 WaitType=e_waitPipeGetRow nodeId=87    60
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server            
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server            
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server            
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2aacd7b5800 WaitType=e_waitPipeNewRow nodeId=79    60
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server            
RUNNING SELECT  0   Microsoft JDBC Driver for SQL Server            
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server            
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2a325e71400 WaitType=e_waitPipeNewRow nodeId=87    60
RUNNABLE    SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2a285ce1b80 WaitType=e_waitPipeNewRow nodeId=66    60
RUNNABLE    SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2a285ce1980 WaitType=e_waitPipeGetRow nodeId=66    60
RUNNABLE    SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2aacd7b5a00 WaitType=e_waitPipeGetRow nodeId=79    60
RUNNABLE    SELECT  0   Microsoft JDBC Driver for SQL Server            
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2a325e70e80 WaitType=e_waitPipeGetRow nodeId=87    60
SUSPENDED   SELECT  0   Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2bec74a5280 WaitType=e_waitPipeGetRow nodeId=83    60
SUSPENDED   SELECT  37  Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2b98d69f700 WaitType=e_waitPipeGetRow nodeId=48    60
SUSPENDED   SELECT  37  Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2b98d69f300 WaitType=e_waitPipeGetRow nodeId=48    60
SUSPENDED   SELECT  37  Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2b98d69f900 WaitType=e_waitPipeGetRow nodeId=48    60
SUSPENDED   SELECT  37  Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2b98d69f400 WaitType=e_waitPipeGetRow nodeId=48    60
SUSPENDED   SELECT  38  Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2b98d69f800 WaitType=e_waitPipeGetRow nodeId=48    60
SUSPENDED   SELECT  37  Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2b98d69fa80 WaitType=e_waitPipeGetRow nodeId=48    60
SUSPENDED   SELECT  37  Microsoft JDBC Driver for SQL Server    CXPACKET    exchangeEvent id=Pipe2b98d69f500 WaitType=e_waitPipeGetRow nodeId=48    60

在这种情况下,我如何发现确切的问题?

致谢

0 个答案:

没有答案