Stored procedures are slow to execute by programs and third-party clients, and SQL Server Management Studio performs normally

Source: Internet
Author: User
Tags management studio sql server management sql server management studio

From: http://blog.csdn.net/pgbiao/article/details/22388945

Cause Analysis:
Because the stored procedure is precompiled, the execution plan is generated at the time of the first execution and is executed at a later time, using the execution plan (unless the stored procedure or the display specifies recompilation) instead of generating the execution plan each time it executes.
The stored procedure should be recompiled when the object structure involved in the stored procedure is adjusted, or the related data has changed greatly, which may result in the original plan being unsuitable for the current situation (the execution plan expires).

Workaround:

1. Manual re-compilation:

EXEC sp_recompile @objname=' stored procedure name '

2, if the execution of low-frequency stored procedures, you can set in the script to perform automatic recompilation every time, such as:

ALTER PROC [dbo]. [ stored procedure name ] @bDate DATETIME , @eDate DATETIME  with -- setting up recompilation to avoid program call timeouts  as BEGIN

Stored procedures are slow to execute by programs and third-party clients, and SQL Server Management Studio performs normally

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.