Reputation: 352
I am an Novice SQL server user and by boss has asked me to record transaction log growth.I am testing transaction log behavior on a dummy database for my production server and do not understand certain things. The production server will have only bulk inserts on the database(around 250 - 400 bulk inserts a day). The methods tested are
The database is in bulk log mode as all the inserts are in bulk. The log file was initially set to 3 GB and in the first scenario the log file size remained the same only the Log space used increased.
DBCC SQLPERF(Logspace)
While in the second case when the bulk insert was performed the log file size increase to a whooping 27 GB but the space used remained minimal 0.5%. I am not understanding the sudden increase in the log size while the space used is still minimal. Does Begin /Commit/Rollback transaction have any effect on transaction logs? Data is being inserted only once in the day, So is keeping a production database in simple recovery mode really stupid?
Upvotes: 1
Views: 1433
Reputation: 171178
Does Begin /Commit/Rollback transaction have any effect on transaction logs?
All log data since the oldest active transaction must be kept active. Now why is only 0,5% of that space in the log used? SQL Server reserves log space for active transactions to support rollback operations. A rollback uses log space. SQL Server is conservative when it reserves space. The 27GB are probably its estimate for how much log is needed in the worst case to rollback all the bulk inserts you made.
You are probably getting minimally logged bulk inserts here. These cause minimal log writes. But the surprise comes later when you back up the log: All bulk-changed pages are copied into the backup so that the log will actually be able to roll-forward the writes you made.
Can you use the simple logging model? That might make these concerns go away. The simple log model does not cause data safety issues by itself. It just means that you can no longer do log backups (which might imply a higher risk for data not backed up yet in case the server explodes).
Whether you should use a single transactions or multiple smaller ones depends on:
Upvotes: 1