谢谢你在这里提供的建议。我们已经找到了一个解决方案,它确实与参数有关。由于“参数嗅探”,SQLServer 在从 SSRS 报告执行时生成了一个复杂的执行计划。解决方案是在存储过程中声明变量,并将传入的参数分配给变量。然后查询使用变量而不是参数。这导致无论是从 SQLServer 管理器还是通过 SSRS 报表调用查询,查询都执行一致的操作。
I had the same scenario occuring..Very basic report, the SP (which only takes in 1 param) was taking 5 seconds to bring back 10K records, yet the report would take 6 minutes to run. According to profiler and the RS ExecutionLogStorage table, the report was spending all it's time on the query. Brian S.'s comment led me to the solution..I simply added WITH RECOMPILE before the AS statement in the SP, and now the report time pretty much matches the SP execution time.
实际上,问题在于,即使 SP 生成了结果,但 SSRS 引擎仍然需要花时间读取这么多行并将其呈现回来。
So I added WITH RECOMPILE option in SP and ran the report .. this is when miracle happened and my problem got resolve.