SQL Server log files

Source: Internet
Author: User

process: yesterday afternoon the database ran, the performance is not even on the database, restart service after the good.

Query Japanese files, "autogrow of file ' Xx_log ' in database ' XX ' is cancelled by the user or timed out after 1896 milliseconds. Use ALTER DATABASE to set a smaller filegrowth value for this file or to explicitly set a new file size.

Find reason: The database is growing automatically, so the connection times out.

Analysis: The database log file is full and starts to grow automatically, automatically growing by default of 10%. There was no problem at this early stage, but it was late. The log file is huge, there are dozens of G, dozens of g of 10% also have a few g, so go to disk and then allocate so much space, it is easy to timeout.

Workaround: 1, the automatic growth mode is set to fixed, too small, easy to cause disk fragmentation, too big easy to time out. The general 500M is no problem.

2. Periodically shrink the log files.

Other: SQL Server database files have MDF files and LDF files. MDF is a data file, and LDF is a log file. If you have a complete log file, you can restore the database to a state at any point in time. The importance of the log file is visible, but the log file generally grows fast, so you need to shrink periodically.

 Use[Master]  GO  ALTER DATABASEDatabase nameSETRECOVERY Simple withno_waitGO  ALTER DATABASEDatabase nameSETRECOVERY Simple--Simple ModeGO   UseRkGO  DBCCShrinkfile (N'Database name _log',2, truncateonly)--after setting the compressed log size to 2M, you can specify your ownGO   Use[Master]  GO  ALTER DATABASEDatabase nameSETRECOVERY Full  withno_waitGO  ALTER DATABASEDatabase nameSETRECOVERY Full  --revert to Full modeGO  

Can be divided into three steps, the data table is set to Simple mode, contraction, and then set back to full mode.

Database has three modes, simple recovery model, full recovery model, bulk-Logged recovery model

, you can see here https://www.cnblogs.com/OpenCoder/p/5708226.html

SQL Server log files

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.