HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

SQL Server Transaction Log Initial Data Load

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
logsqltransactioninitialloadserverdata

Problem

What is the standard process when initially populating a database with 5GB+ to avoid a large transaction log? From my understanding the log file would jump to a large size after the initial load and not decrease in disk space from that point on. Regular transaction log backups would free up space within the file, but the file would remain large.

Is it advisable then to set the target database to simple backup, load the data, use CHECKPOINT to truncate log, and then set the database to full backup mode?

Additionally, I know there is a shrink file operation that can be performed on the log, but some say never to use it, others seem to recommend it as a solution. Any thoughts?

Solution

Use bulk operations - the bcp command-line utility or BULK INSERT commands, they can generate much smaller transaction logs and they are way way faster. See this for details about the transaction log generation.

(I am answering for Microsoft SQL Server, but equivalent utilities and command are available for all databases)

Context

StackExchange Database Administrators Q#23501, answer score: 2

Revisions (0)

No revisions yet.