Knowledge Base
MilesWeb / Database

How to Reduce/Shrink the SQL File Size?

Approx. read time : 3 min

Reducing or shrinking the size of an SQL file is beneficial for different reasons. It helps to optimize the storage space, improve the performance. SQL files, over the time, can grow large in size due to higher amounts of data storage, indexes and other elements.

When you’re using the SQL server with iBase, 2 SQL databases are created, one is for the data and the other is for the Logs. SQL server then creates a Log file for every database. This log file is an internal SQL server file, and does not impact the iBase.

However, at some times, the size of the log file grows immensely and it starts blocking the SQL server.

In this article, we will discuss how to reduce/shrink the SQL file size.

iBase might take longer to respond, or you receive an error message saying that there is no more free space on the disk.

This happens, due to the below reasons:

By default, when SQL creates a database, it does not create a Log file for this database.

One option of this database is the Recovery Mode, which gets full.

Environment

SQL Server Storage

How to Diagnose the Issue?

In Windows, click on the folder where the database files are stored. Then, search for the files with an LDF extension, and then check the size of the files.

If files are large in size, you might want to reduce or shrink them.

Steps to Reduce/Shrink the SQL File Size:

In order to shrink the Transaction log in the SQL Server Management Studio.

  1. First, right-click on the database, and then, choose Properties, then Options.
  2. Ensure that the “Recovery mode” is set to “Simple”, not “Full”, and then click on OK.
  3. Right-click on the database again, choose Tasks > Shrink Files.
  4. Now, change the file type to “Log.”
  5. Lastly, click OK.

Once you have performed these steps, check in the folder if the size has been reduced.

Alternatively, for SQL to do it successfully:

  • SQL queries:
  • *ALTER DATABASE mydatabase SET RECOVERY SIMPLE
  • DBCC SHRINKFILE (mydatabase_Log, 1)*

Warning: In the first sql script, its the main database, and in the 2nd script, its the Log database. 

Once you have completed the steps, check the folder that has been reduced. 

Note: Revert the changes of “Recovery model” from Simple to Full once log file shrink is done

Hope you have found this article helpful!

Nehal is an ardent content writer. She's passionate about crafting content that's simple but adds value. Her insatiable interest in writing has allowed her to explore her skills. She is adept and can write for different types of content formats.

Trusted By Thousands of Clients & Big Businesses

We highly appreciate the kind and stellar feedback we receive from our customers. Delivering the best is our goal! MilesWeb is rated Excellent out of 5 based on reviews. Read more reviews.

Excellent
Based on reviews
2 hours ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
4 hours ago
Milesweb is superb Hosting pro...
Milesweb is superb Hosting provider ever, their Support team is amazing!!!...
Abhishek Singh
15 hours ago
Great support in great timing...
We need urgent assistance on changes in a primary domain on our client's Cpanel accounts and reached...
Riyaju Deen
21 hours ago
Best Website Hosting platform ...
I was new on MilesWeb. And needed help on multiple areas from setting up to getting started with cre...
Harshada
1 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
1 days ago
the team is very supportive th...
the team is very supportive though at times effort needs to be made to make understand the problem s...
Suree Sharma
1 days ago
I am using miles web for 3plus...
I am using miles web for 3plus years, very quick and perfect support by the team, they helped me man...
Sri Raghav
2 days ago
The service is good...
The service is good. They are answering with patience and doing the needful as soon as possible....
MR
2 days ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
3 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
4 days ago
positively helped me with find...
positively helped me with finding insecure content on my website causing SSL to not work properly on...
Thaviraj Junglee
4 days ago
Exceptional support, Truly Pra...
I had opted for the basic wordpress hosting plan as I intended to experiment with various plug-ins. ...
Aseem Chandna