Run procedure very slowly but run procedure content quickly

Source: Internet
Author: User

Problem Description:

Once in the release system to production environment, suddenly found the report after several minutes also refresh not come out, small brother I directly panicked. Quickly carry out a variety of tests, the first right key report properties to find the report address to see if the parameters are transmitted correctly. Find the report parameters directly after running procedure, also can not run out. Open procedure A section of implementation is no problem, the implementation of the entire procedure content is no problem, but exec procedure_nm has always been a problem. It's okay to execute procedure in the development environment. So, began to tangle.

Environment: SQL SERVER 2008, SSRS 2008

Resolution process:

Think carefully about the difference between production environment and development environment, it is the development environment is a newly built environment, production is already existed for several years of environment, this time only to its report producdure changed, and played a patch to modify the previous half of the historical data. It turned out that this was the main cause of the event. By constantly looking for problems, we found the table statistics in the development environment and production (the bottom item after the table is expanded in the left target browser in SQL Server: Statistics). It was just a guess that a lot of new data would cause production statistics to be obsolete, and the SQL Server engine would make a series of data retrieval plans based on statistics when parsing procedure, just as there was a highway from city A to B, Now that the freeway is useless, the SQL Server engine is looking for other stupid methods, and the automatic updating of statistics will only happen in the dead of night. So they try to apply for a manual update of production statistics. After the statistics are updated, the report opens normally.

Workaround:

Use DATABASE_NM

EXEC sp_updatestats

Conclusion:

After a large amount of data is updated, the statistics of the database are changed, which in turn affects SQL Server parsing of SQL. You need to update the database statistics so that SQL Server has the latest and correct information to make the execution plan.

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.