I use sqlserver-jdbc driver execute query in java, have wait about 700s before returning result set, but it's only 50s when I do this with navicat or SSMS instead. Anybody has similar problem, I can't find reason since I don't know datebase much,.
我在java中使用sqlserver-jdbc驱动程序执行查询,在返回结果集之前要等待大约700秒,但是当我使用navicat或SSMS执行此操作时,它只有50秒。任何人都有类似的问题,我找不到原因,因为我不太了解datebase。
1 个解决方案
#1
0
Use that script to get cached execution plans of your SP:
使用该脚本获取SP的缓存执行计划:
SELECT cp.objtype AS ObjectType,
OBJECT_NAME(st.objectid,st.dbid) AS ObjectName,
cp.usecounts AS ExecutionCount,
st.TEXT AS QueryText,
qp.query_plan AS QueryPlan
FROM sys.dm_exec_cached_plans AS cp
CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) AS qp
CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) AS st
WHERE objtype ='Proc' AND OBJECT_NAME(st.objectid,st.dbid) = '__YOUR_SP_NAME__';
I suppose that SSMS and sqlserver-jdbc driver use different cached plans.
我想SSMS和sqlserver-jdbc驱动程序使用不同的缓存计划。
#1
0
Use that script to get cached execution plans of your SP:
使用该脚本获取SP的缓存执行计划:
SELECT cp.objtype AS ObjectType,
OBJECT_NAME(st.objectid,st.dbid) AS ObjectName,
cp.usecounts AS ExecutionCount,
st.TEXT AS QueryText,
qp.query_plan AS QueryPlan
FROM sys.dm_exec_cached_plans AS cp
CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) AS qp
CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) AS st
WHERE objtype ='Proc' AND OBJECT_NAME(st.objectid,st.dbid) = '__YOUR_SP_NAME__';
I suppose that SSMS and sqlserver-jdbc driver use different cached plans.
我想SSMS和sqlserver-jdbc驱动程序使用不同的缓存计划。