would DBCC shrinkfile cause any blocking or any hit to an OLTP environment
while its running. Ive got a lot of extra space on some data files that I
want to shrink and was wondering if its safe to do it during our peak
hours... What does it do internally ? Any locking ,etc..Using SQL 2000Yes. It issues a lot of IO and takes short term X page locks. In internal
tests we've seen up to 20% drop in transaction throughput, depending on the
exact workload and hardware configuration. This is unavoidable due to the
operations shrink has to perform.
What proportion of the database size is free-space? Consider not doing the
shrink unless you're really desperate for the disk space or you *know* the
database size won't grow again. If you shrink, the odds are that the
database will have to grow again anyway. As always, depends on your exact
workload etc etc
It is always 'safe' to do a shrink.
Regards
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:uBcDfwnFEHA.2876@.TK2MSFTNGP09.phx.gbl...
> would DBCC shrinkfile cause any blocking or any hit to an OLTP environment
> while its running. Ive got a lot of extra space on some data files that I
> want to shrink and was wondering if its safe to do it during our peak
> hours... What does it do internally ? Any locking ,etc..Using SQL 2000
>
Showing posts with label oltp. Show all posts
Showing posts with label oltp. Show all posts
Thursday, March 29, 2012
Tuesday, March 27, 2012
DBCC SHRINKDATABASE QUESTION
I am archiving about 25 gigs of images from our OLTP database to an archive database. After archiving these images(table which contains a column datatype image), there is about 25 gigs of unallocated space reported by EM. I run the normal Shrink database routine
DBCC SHRINKDATABASE
( database_name [ , target_percent ] )
--I set the target percent low(about 5%), current db size after archive is 75 gigs so it should shrink to about 79 gigs...
and instead of releasing the free space to the operating system the routine actually increases the used space of the db to fill almost all the newly freed space. Basically I remove 25 gigs of data, run the routine and now magically the database grows 25 gigs instead of freeing up 25 gigs.(now the db is back to the orginal size before archive process!!) I've only experienced this when dealing with image datatypes. I am wondering if the way images are stored has something to do with this unexpected behavior. If anybody has any insight please let me know. ThanksYes this is a know issue that it can happen sometimes but I don't know if
there is a KB regarding this or not. Try using DBCC CLEANTABLE and see if
that helps. If not then you might have to BCP out all the data from that
table, truncate it and bcp it back in.
--
Andrew J. Kelly
SQL Server MVP
"mike petanovitch" <mpetanovitch@.hotmail.com> wrote in message
news:5DB04B5D-64C6-4422-AEB4-A1E99BEE8574@.microsoft.com...
> I am archiving about 25 gigs of images from our OLTP database to an
archive database. After archiving these images(table which contains a
column datatype image), there is about 25 gigs of unallocated space reported
by EM. I run the normal Shrink database routine:
> DBCC SHRINKDATABASE
> ( database_name [ , target_percent ] )
> --I set the target percent low(about 5%), current db size after archive is
75 gigs so it should shrink to about 79 gigs...
> and instead of releasing the free space to the operating system the
routine actually increases the used space of the db to fill almost all the
newly freed space. Basically I remove 25 gigs of data, run the routine
and now magically the database grows 25 gigs instead of freeing up 25
gigs.(now the db is back to the orginal size before archive process!!)
I've only experienced this when dealing with image datatypes. I am
wondering if the way images are stored has something to do with this
unexpected behavior. If anybody has any insight please let me know. Thanks
DBCC SHRINKDATABASE
( database_name [ , target_percent ] )
--I set the target percent low(about 5%), current db size after archive is 75 gigs so it should shrink to about 79 gigs...
and instead of releasing the free space to the operating system the routine actually increases the used space of the db to fill almost all the newly freed space. Basically I remove 25 gigs of data, run the routine and now magically the database grows 25 gigs instead of freeing up 25 gigs.(now the db is back to the orginal size before archive process!!) I've only experienced this when dealing with image datatypes. I am wondering if the way images are stored has something to do with this unexpected behavior. If anybody has any insight please let me know. ThanksYes this is a know issue that it can happen sometimes but I don't know if
there is a KB regarding this or not. Try using DBCC CLEANTABLE and see if
that helps. If not then you might have to BCP out all the data from that
table, truncate it and bcp it back in.
--
Andrew J. Kelly
SQL Server MVP
"mike petanovitch" <mpetanovitch@.hotmail.com> wrote in message
news:5DB04B5D-64C6-4422-AEB4-A1E99BEE8574@.microsoft.com...
> I am archiving about 25 gigs of images from our OLTP database to an
archive database. After archiving these images(table which contains a
column datatype image), there is about 25 gigs of unallocated space reported
by EM. I run the normal Shrink database routine:
> DBCC SHRINKDATABASE
> ( database_name [ , target_percent ] )
> --I set the target percent low(about 5%), current db size after archive is
75 gigs so it should shrink to about 79 gigs...
> and instead of releasing the free space to the operating system the
routine actually increases the used space of the db to fill almost all the
newly freed space. Basically I remove 25 gigs of data, run the routine
and now magically the database grows 25 gigs instead of freeing up 25
gigs.(now the db is back to the orginal size before archive process!!)
I've only experienced this when dealing with image datatypes. I am
wondering if the way images are stored has something to do with this
unexpected behavior. If anybody has any insight please let me know. Thanks
Friday, February 17, 2012
Dbcc checkdb for highly OLTP system
Is it advisable to run DBCC checkdb for all databases daily on a highly OLTP
system ?
Or is it better to do it once a week or once a month..?
What about dbcc dbreindex ? When does one do that on a highly transactional
system..
Using SQL 2000It won't hurt to run DBCC CHECKDB and DBCC DBREINDEX (or DBCC INDEXDEFRAG)
as often as possible. How often you can run it is usually limited by the
maintenance window you have. If you have time to run them every night, run
them every night. You should run them at least once a week.
DBCC DBREINDEX takes out table locks, so you can't really use that in a 24/7
environment, but you can run DBCC CHECKDB and DBCC INDEXDEFRAG during
periods with low activity.
In both cases (overnight maintenance windows and 24/7) you can choose to run
DBCC INDEXDEFRAG and DBCC CHECKTABLE (instead of DBCC CHECKDB) on a limited
number of different tables only each day, so that you won't exceed your
maintenance window. Be warned though that DBCC CHECKDB can take a lot longer
to complete when it actually encounters problems. I saw the execution time
on one of my servers go from about 25 minutes to about 2.5 hours when an
index got corrupted.
--
Jacco Schalkwijk MCDBA, MCSD, MCSE
Database Administrator
Eurostop Ltd.
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:%23XG5hlOeDHA.1700@.TK2MSFTNGP10.phx.gbl...
> Is it advisable to run DBCC checkdb for all databases daily on a highly
OLTP
> system ?
> Or is it better to do it once a week or once a month..?
> What about dbcc dbreindex ? When does one do that on a highly
transactional
> system..
> Using SQL 2000
>
>|||IN addition to Jacob's comments you can also restore a copy of the db on
another server and run DBCC CHECKDB there. That way you don't have to
bother the users at all and it will still tell you if you have corruption or
not.
--
Andrew J. Kelly
SQL Server MVP
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:%23XG5hlOeDHA.1700@.TK2MSFTNGP10.phx.gbl...
> Is it advisable to run DBCC checkdb for all databases daily on a highly
OLTP
> system ?
> Or is it better to do it once a week or once a month..?
> What about dbcc dbreindex ? When does one do that on a highly
transactional
> system..
> Using SQL 2000
>
>|||Sorry Jacco, darn spell checkers<g>.
Andrew J. Kelly
SQL Server MVP
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:OCWiAjSeDHA.1716@.TK2MSFTNGP10.phx.gbl...
> IN addition to Jacob's comments you can also restore a copy of the db on
> another server and run DBCC CHECKDB there. That way you don't have to
> bother the users at all and it will still tell you if you have corruption
or
> not.
> --
> Andrew J. Kelly
> SQL Server MVP
>
> "Hassan" <fatima_ja@.hotmail.com> wrote in message
> news:%23XG5hlOeDHA.1700@.TK2MSFTNGP10.phx.gbl...
> > Is it advisable to run DBCC checkdb for all databases daily on a highly
> OLTP
> > system ?
> > Or is it better to do it once a week or once a month..?
> >
> > What about dbcc dbreindex ? When does one do that on a highly
> transactional
> > system..
> >
> > Using SQL 2000
> >
> >
> >
>|||Re: reindex/indexdefrag - check out the white paper at
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/sql/maintain/optimize/ss2kidbp.asp
which not only helps you work out which command will work best for you, it
also tells you how to determine if you even need to bother spending the time
running eitehr command. Just because an index is fragmented, it doesn't
necessarily follow that running either command will have any effect on the
performance of your workload.
Re: checkdb - if you're going to run it nightly, I advise you to use the
WITH PHYSICAL_ONLY option. This will audit every page, perform an allocation
consistency check, and structural checks of B-trees. You should not run with
any of the repair options by default.
Regards,
Paul.
--
Paul Randal
DBCC Technical Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:#XG5hlOeDHA.1700@.TK2MSFTNGP10.phx.gbl...
> Is it advisable to run DBCC checkdb for all databases daily on a highly
OLTP
> system ?
> Or is it better to do it once a week or once a month..?
> What about dbcc dbreindex ? When does one do that on a highly
transactional
> system..
> Using SQL 2000
>
>
system ?
Or is it better to do it once a week or once a month..?
What about dbcc dbreindex ? When does one do that on a highly transactional
system..
Using SQL 2000It won't hurt to run DBCC CHECKDB and DBCC DBREINDEX (or DBCC INDEXDEFRAG)
as often as possible. How often you can run it is usually limited by the
maintenance window you have. If you have time to run them every night, run
them every night. You should run them at least once a week.
DBCC DBREINDEX takes out table locks, so you can't really use that in a 24/7
environment, but you can run DBCC CHECKDB and DBCC INDEXDEFRAG during
periods with low activity.
In both cases (overnight maintenance windows and 24/7) you can choose to run
DBCC INDEXDEFRAG and DBCC CHECKTABLE (instead of DBCC CHECKDB) on a limited
number of different tables only each day, so that you won't exceed your
maintenance window. Be warned though that DBCC CHECKDB can take a lot longer
to complete when it actually encounters problems. I saw the execution time
on one of my servers go from about 25 minutes to about 2.5 hours when an
index got corrupted.
--
Jacco Schalkwijk MCDBA, MCSD, MCSE
Database Administrator
Eurostop Ltd.
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:%23XG5hlOeDHA.1700@.TK2MSFTNGP10.phx.gbl...
> Is it advisable to run DBCC checkdb for all databases daily on a highly
OLTP
> system ?
> Or is it better to do it once a week or once a month..?
> What about dbcc dbreindex ? When does one do that on a highly
transactional
> system..
> Using SQL 2000
>
>|||IN addition to Jacob's comments you can also restore a copy of the db on
another server and run DBCC CHECKDB there. That way you don't have to
bother the users at all and it will still tell you if you have corruption or
not.
--
Andrew J. Kelly
SQL Server MVP
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:%23XG5hlOeDHA.1700@.TK2MSFTNGP10.phx.gbl...
> Is it advisable to run DBCC checkdb for all databases daily on a highly
OLTP
> system ?
> Or is it better to do it once a week or once a month..?
> What about dbcc dbreindex ? When does one do that on a highly
transactional
> system..
> Using SQL 2000
>
>|||Sorry Jacco, darn spell checkers<g>.
Andrew J. Kelly
SQL Server MVP
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:OCWiAjSeDHA.1716@.TK2MSFTNGP10.phx.gbl...
> IN addition to Jacob's comments you can also restore a copy of the db on
> another server and run DBCC CHECKDB there. That way you don't have to
> bother the users at all and it will still tell you if you have corruption
or
> not.
> --
> Andrew J. Kelly
> SQL Server MVP
>
> "Hassan" <fatima_ja@.hotmail.com> wrote in message
> news:%23XG5hlOeDHA.1700@.TK2MSFTNGP10.phx.gbl...
> > Is it advisable to run DBCC checkdb for all databases daily on a highly
> OLTP
> > system ?
> > Or is it better to do it once a week or once a month..?
> >
> > What about dbcc dbreindex ? When does one do that on a highly
> transactional
> > system..
> >
> > Using SQL 2000
> >
> >
> >
>|||Re: reindex/indexdefrag - check out the white paper at
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/sql/maintain/optimize/ss2kidbp.asp
which not only helps you work out which command will work best for you, it
also tells you how to determine if you even need to bother spending the time
running eitehr command. Just because an index is fragmented, it doesn't
necessarily follow that running either command will have any effect on the
performance of your workload.
Re: checkdb - if you're going to run it nightly, I advise you to use the
WITH PHYSICAL_ONLY option. This will audit every page, perform an allocation
consistency check, and structural checks of B-trees. You should not run with
any of the repair options by default.
Regards,
Paul.
--
Paul Randal
DBCC Technical Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:#XG5hlOeDHA.1700@.TK2MSFTNGP10.phx.gbl...
> Is it advisable to run DBCC checkdb for all databases daily on a highly
OLTP
> system ?
> Or is it better to do it once a week or once a month..?
> What about dbcc dbreindex ? When does one do that on a highly
transactional
> system..
> Using SQL 2000
>
>
Subscribe to:
Posts (Atom)