But what does it do? And why is so big?
Do I need them? Should they be big?
Main Topics
Browse All TopicsHi.
I have a large number of databases on my MS SQL server.
There are files .MDF and .LDF files. From what I can tell (and I may well be VERY wrong here), the MDF file is the REAL data. The LDF file are changes yet to be merged into the live data.
The databases are either for testing (i.e. product development) or from customers for us to determine product faults. (i.e. I can play with this).
1 - What are the LDF files?
2 - Why are they so big?
3 - When do "transactions" become part of the "data"?
4 - If the data was merged more often (or as soon as the update was made), would the application perform faster?
If it makes any difference, we are using Delphi with ODBC Express and using the MS SQL ODBC driver for communication.
We tried limiting the size of the log file (within Enterprise Manager). The application then complained saying the log file is full and the update failed.
Thanks in advance.
Richard Quadling.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The size of the log file(ldf) is determined my the logging level you have set up on the database. Simple, full, and buld loged are the options. Simple being the least, and full being the most. The log (if in full) will alow you to re-apply transactions to the databse incase of a failure. If your looking for some performance improvement, there are a lot of things that can be done.
Just to focus on the files you could more the location of the LDF file to a separate physical drive. This will increate performance because writing to the log and writing to the mdf files wont compete for each other for throughput tot he drive. You can also create a NDF file for the databese, and change some of the tables to be stored on this NDF. This file also could be stored on a separate physical drive. Some advantages to this are:
Tables that are written to most frequently are stored in one file, and tables that are relatively static are in another. Having to smaller file to write to for transactions will help with throughput.
In order for full logging to be utalized, you need to be making backups of the log files on a regular basis(multiple times a day in some cases). Also a desaster recovery plan should be developed. If this is not the case, you may want to consider a simple logging method. This is the smallest and will log to let you know what happend, but does not have enough information in it to help with restoring transactions. All data would be lost cence your past backup, in a failure.
If your LDF files are REALLY big, it means that you probably don't backup the logs on a regular basis.
(After a log is backed up it's sort of "emptied". It's still just as big but the space can be reused by SQL server, so it doesn't grow to enormous proportions).
So create a maintenance plan to backup the log on a regular basis.
(just test by looking at the free space in the database, backup the log and check the free space again)
I once saw a script to rearrange the "emptied" log so it shrinks in size as well, but i'll have to look it up. I'll post it here in about 24 hours.
Please see this Books Online article to better understand what and why LDF files are:
http://msdn.microsoft.
P
http://msdn.microsof
Business Accounts
Answer for Membership
by: adwisemanPosted on 2004-02-02 at 08:03:48ID: 10253339
MDF is the main database files, LDF is the log files, NDF are secondary databse files. Same as mdf, but you can only have 1 Main databse file.