SQL Server My query runs very fast in SSMS, but very slow in other applications [duplicate]

8nuwlpux  于 2023-08-02  发布在  其他
关注(0)|答案(1)|浏览(113)

This question already has answers here:

OPTION (RECOMPILE) is Always Faster; Why? (6 answers)
Closed 12 days ago.

I have an application that uses a T-SQL query and queries SQL Server. I just wanted to know if 2 users from 2 different machines running the application, does the SQL Server cache the results after the first user runs the application? And if so, where does the cache happen? Does it happen on the host server where the SQL Server is installed on? Or on the machine, that application is installed on?

My problem is that I have a query that runs very fast in SQL Server Management Studio, but is very slow when it gets called from the application.

Thank you!

nkoocmlb

nkoocmlb1#

A long-shot suggestion for you. Change the query in your application to end with OPTION(RECOMPILE) . It may be that SQL server is hanging on to a no-longer-optimal execution plan. Worth a try.

相关问题