473,379 Members | 1,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Problem In Doing Shrink Database

hi all,

This will be a easy question for all out here.
I have a database of 28GB.
having 3 Data Files 22 GB, 3.58 Gb and 2.70 GB respectively.
and a Transaction Log file of 156 mb.

When i executed DBCC Shrinkdatabase(databasename),it reduced
size of datafile but the LOG file had gone up to 5 Gb from 156mb.

I want to know why this happened and how should i shrink Log File or
any other option.
One more doubt how does Dbcc ShrinkDatabase help in performance.

A kick to a right direction will be helpfull to me.

Thanks in advance
tv

ps
I also used DBCC SHRINKFILE(database_log)but their was no change
in size of log file.

Jul 23 '05 #1
4 6702
(To***********@gmail.com) writes:
This will be a easy question for all out here.
I have a database of 28GB.
having 3 Data Files 22 GB, 3.58 Gb and 2.70 GB respectively.
and a Transaction Log file of 156 mb.

When i executed DBCC Shrinkdatabase(databasename),it reduced
size of datafile but the LOG file had gone up to 5 Gb from 156mb.
Yes, shrinking a data file is a logged operation - so that the shrinking
can be rolled back, if someone pulls the power chord while the shrinking
is running. And since shrinking can require to move a whole lot around,
you can bet that your log will grow.
I want to know why this happened and how should i shrink Log File or
any other option.
You can use DBCC SHRINKFILE to shrink the log. If you are running in
full or bulk-logged recovery, then your first need to backup the
transaction log.
One more doubt how does Dbcc ShrinkDatabase help in performance.


There is rarely any need to shrink databases. Do this, only if you
have removed a lot of data, and you know that this amount will not
come back. Else the database will have to grow again, and autogrow
is a fairly expensive operation.

What I would consider, though, is to run SHRINKFILE on the small files
with the EMPTYFILE option, and then drop these with ALTER DATABASE
REMOVE FILE.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #2
The logfile will shrink down to the virtual log file boundary.. Backup
the transaction log first then try shrinking the file..

greg

Jul 23 '05 #3
One small clarification - although everything is logged during a shrink,
each page is moved inits own transaction internally so if the power cord is
pulled, only the last page move needs to be rolled-back. All previous work
is committed and is not lost.

Thanks

--
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine

This posting is provided "AS IS" with no warranties, and confers no rights.

"Erland Sommarskog" <es****@sommarskog.se> wrote in message
news:Xn**********************@127.0.0.1...
(To***********@gmail.com) writes:
This will be a easy question for all out here.
I have a database of 28GB.
having 3 Data Files 22 GB, 3.58 Gb and 2.70 GB respectively.
and a Transaction Log file of 156 mb.

When i executed DBCC Shrinkdatabase(databasename),it reduced
size of datafile but the LOG file had gone up to 5 Gb from 156mb.


Yes, shrinking a data file is a logged operation - so that the shrinking
can be rolled back, if someone pulls the power chord while the shrinking
is running. And since shrinking can require to move a whole lot around,
you can bet that your log will grow.
I want to know why this happened and how should i shrink Log File or
any other option.


You can use DBCC SHRINKFILE to shrink the log. If you are running in
full or bulk-logged recovery, then your first need to backup the
transaction log.
One more doubt how does Dbcc ShrinkDatabase help in performance.


There is rarely any need to shrink databases. Do this, only if you
have removed a lot of data, and you know that this amount will not
come back. Else the database will have to grow again, and autogrow
is a fairly expensive operation.

What I would consider, though, is to run SHRINKFILE on the small files
with the EMPTYFILE option, and then drop these with ALTER DATABASE
REMOVE FILE.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Jul 23 '05 #4
Paul S Randal [MS] (pr*****@online.microsoft.com) writes:
One small clarification - although everything is logged during a shrink,
each page is moved inits own transaction internally so if the power cord
is pulled, only the last page move needs to be rolled-back. All previous
work is committed and is not lost.


Thanks for the correction, Paul!
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jaeger | last post by:
Hi all. I'm having trouble shrinking a database. In short, using the SQL Query Analyzer, I enter the following commands: DBCC SHRINKDATABASE (database, 80) GO The command returns the...
7
by: Graham Taylor | last post by:
I've tried posting this in the 'microsoft.public.access' but I will post it here also, as I think it might be the webserver which is causing my problem. --------- I have an Access 2003 database...
3
by: war_wheelan | last post by:
I am having a problem backing up my database and TLog files due to a lack of local diskspace. The db file is about 30GB and the TLog is about 20GB each on a different hard disk. Each disk doesn't...
4
by: xunitinmullik | last post by:
Hello ppl: I am facing a problem that I ahve never experienced before with the secured database. I created an MS Access 2000 application (.mdb) using MS Access 2002 and secured it using exactly...
0
by: Tom Wild | last post by:
Hi I am trying to connect to an Access database from a WebPage in VB.Net but when I try to open the connection I get the following error: The Microsoft Jet database engine cannot open the file...
0
by: Tom Wild | last post by:
Hi I am creating a webform in VB.Net which connects to an Access database. I can get the webform to connect to the database fine and also to download data but when I try and update the...
0
by: mahesh123 | last post by:
Hi, I am new to use the crystal reports8.0. I am facing the problem regarding the database connection through the ADO Connection. Suppose my database name is "sample.pra"(due to some security...
1
by: MANU1k | last post by:
My database properties show Space Available 0.00 MB. And users complain the application is very slow. Do i need to do a database shrink? Also can i schedule db shrink on a weekly basis is that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.