search
HomeBackend DevelopmentPHP TutorialHow to prevent Microsoft SQL Server log files from growing larger? _PHP Tutorial

How to reduce the size of MSSQL log files is a frequent question, but there are already many answers to this question in the essence area, so I won’t go into details here.
Now let’s discuss the fundamental problem, that is, how to prevent the log file from growing larger?
First introduce a simple method.
Just set the database's failure recovery model to "Simple" (SQL2K). This way it will truncate the log during Checkpoint.
The specific operation method is:
1. Right-click the database in Enterprise Manager, "Properties | Options | Fault Recovery", select "Simple", if it is SQL7, there is A "trunc. log on chkpt. ", just select it.
2. If you don’t want to use Enterprise Manager, execute
EXEC sp_dboption 'your_dbname', 'trunc. log on chkpt.', 'TRUE'
in Query Analyser or isql. However, It should be noted that after doing this, although the log will not increase, it also means that once you make a mistake, you will not have the opportunity to use the log to recover. (For how to use logs to recover, please see the FAQ in the essence area)
Therefore, it is absolutely not recommended to truncate logs on a production database, unless you have sufficient reasons and sufficient assurance, or...
It is not you who bears the responsibility. .
Since this method is not safe, I will introduce a safe method below.
As everyone knows, SQL Server will automatically truncate the inactive portion of the transaction log when completing a transaction log backup. These inactive sections contain completed transactions and are therefore no longer used during the recovery process. In contrast, the active portion of the transaction log contains transactions that are still running but have not yet completed. SQL Server will reuse this truncated inactive space in the transaction log rather than allowing the transaction log to continue to grow and take up more space.
So, by backing up the transaction log, the log file will no longer grow.
However, leaving the log file always is not an option. If you delete it, you will lose the possibility of recovery.
We can do it in conjunction with a full backup. The transaction log before the full backup can be deleted.
For example, a backup plan includes a full backup every day and keeps it for 7 days, and a transaction log backup every 15 minutes and keeps it for 2 days.
Using the Database Maintenance Plan Wizard can easily create a backup plan, but you must remember to set how long the backup should be retained, otherwise it will be a bad thing if the hard disk space is filled up by the backup.
Wrotten by Lucky@Dev-club
March 8, 2002

http://www.bkjia.com/PHPjc/631146.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631146.htmlTechArticleHow to shrink the MSSQL log file is already a recurring problem, but this problem has been discussed in the essence area. There are no answers, so I won’t go into details here. Now let’s discuss treatment...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP Performance Tuning for High Traffic WebsitesPHP Performance Tuning for High Traffic WebsitesMay 14, 2025 am 12:13 AM

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

Dependency Injection in PHP: Code Examples for BeginnersDependency Injection in PHP: Code Examples for BeginnersMay 14, 2025 am 12:08 AM

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

PHP Performance: is it possible to optimize the application?PHP Performance: is it possible to optimize the application?May 14, 2025 am 12:04 AM

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

PHP Performance Optimization: The Ultimate GuidePHP Performance Optimization: The Ultimate GuideMay 14, 2025 am 12:02 AM

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools