Showing posts with label cause. Show all posts
Showing posts with label cause. Show all posts

Sunday, March 25, 2012

Does SQL degrade when DBCC Traceon 1222 is switched on?

Hi,

I'm seeing a few deadlocks on my SQL 2005 production database and wondered what i could expect if i switch on the trace flag 1222. Can this cause more deadlocks to occur? Will the performance of SQL degrade? Is it safe to have this flag set on a production server or is there another method you would recommend?

Thanks

Martin

In general every extra logging causes a little performance impact but it will not cause extra deadlocks. The performance impact is more acceptable than having deadlocks so until you have found the root cause of these deadlocks I would not hesitate to use the trace flag.

Do not bother too much about the performance impact however, it is very little and definitely less than the cost of having deadlocks.

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

Does SQL degrade when DBCC Traceon 1222 is switched on?

Hi,

I'm seeing a few deadlocks on my SQL 2005 production database and wondered what i could expect if i switch on the trace flag 1222. Can this cause more deadlocks to occur? Will the performance of SQL degrade? Is it safe to have this flag set on a production server or is there another method you would recommend?

Thanks

Martin

In general every extra logging causes a little performance impact but it will not cause extra deadlocks. The performance impact is more acceptable than having deadlocks so until you have found the root cause of these deadlocks I would not hesitate to use the trace flag.

Do not bother too much about the performance impact however, it is very little and definitely less than the cost of having deadlocks.

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

sql

Does shrinking a user database cause tempdb to grow?

I'm looking at all the possible issues that may have contributed to an
inexplicably large jump in size for my tempdb. I recall reading an article
or posting that stated shrinking a user database will cause tempdb to grow.
Can anyone provide insight on this?Sorry, I misread "tempdb" as "log file" ... Disregard my previous reply
(although, you should still read that article anyway -- it's very
informative). I'm not aware of any condition that would cause tempdb to
grow during a shrink.
"Rod Bautista" <rod.bautista@.cox.net> wrote in message
news:euzneqjqEHA.2340@.TK2MSFTNGP11.phx.gbl...
> I'm looking at all the possible issues that may have contributed to an
> inexplicably large jump in size for my tempdb. I recall reading an
article
> or posting that stated shrinking a user database will cause tempdb to
grow.
> Can anyone provide insight on this?
>|||Yes:
http://www.karaszi.com/SQLServer/info_dont_shrink.asp
"Rod Bautista" <rod.bautista@.cox.net> wrote in message
news:euzneqjqEHA.2340@.TK2MSFTNGP11.phx.gbl...
> I'm looking at all the possible issues that may have contributed to an
> inexplicably large jump in size for my tempdb. I recall reading an
article
> or posting that stated shrinking a user database will cause tempdb to
grow.
> Can anyone provide insight on this?
>|||AFAIK, tempdb is not used for a shrink. The pages are quite simply moved toward the beginning of the
file.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Rod Bautista" <rod.bautista@.cox.net> wrote in message news:euzneqjqEHA.2340@.TK2MSFTNGP11.phx.gbl...
> I'm looking at all the possible issues that may have contributed to an
> inexplicably large jump in size for my tempdb. I recall reading an article
> or posting that stated shrinking a user database will cause tempdb to grow.
> Can anyone provide insight on this?
>|||Thanks Adam and Tibor.
I thought as much...I was certain somebody stated that in a post and the
idea stuck with me. It didn't make any sense for temdb to be affected
during a shrink operation but I had to throw the question out there.
R
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:u$OUb8jqEHA.3464@.tk2msftngp13.phx.gbl...
> AFAIK, tempdb is not used for a shrink. The pages are quite simply moved
toward the beginning of the
> file.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Rod Bautista" <rod.bautista@.cox.net> wrote in message
news:euzneqjqEHA.2340@.TK2MSFTNGP11.phx.gbl...
> > I'm looking at all the possible issues that may have contributed to an
> > inexplicably large jump in size for my tempdb. I recall reading an
article
> > or posting that stated shrinking a user database will cause tempdb to
grow.
> > Can anyone provide insight on this?
> >
> >
>|||I know others have replied with the same answer, but I'll also say that from
the code in shrink there's nothing that touches or affects tempdb.
--
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Rod Bautista" <rod.bautista@.cox.net> wrote in message
news:euzneqjqEHA.2340@.TK2MSFTNGP11.phx.gbl...
> I'm looking at all the possible issues that may have contributed to an
> inexplicably large jump in size for my tempdb. I recall reading an
article
> or posting that stated shrinking a user database will cause tempdb to
grow.
> Can anyone provide insight on this?
>

Does shrinking a user database cause tempdb to grow?

I'm looking at all the possible issues that may have contributed to an
inexplicably large jump in size for my tempdb. I recall reading an article
or posting that stated shrinking a user database will cause tempdb to grow.
Can anyone provide insight on this?
Yes:
http://www.karaszi.com/SQLServer/info_dont_shrink.asp
"Rod Bautista" <rod.bautista@.cox.net> wrote in message
news:euzneqjqEHA.2340@.TK2MSFTNGP11.phx.gbl...
> I'm looking at all the possible issues that may have contributed to an
> inexplicably large jump in size for my tempdb. I recall reading an
article
> or posting that stated shrinking a user database will cause tempdb to
grow.
> Can anyone provide insight on this?
>
|||Sorry, I misread "tempdb" as "log file" ... Disregard my previous reply
(although, you should still read that article anyway -- it's very
informative). I'm not aware of any condition that would cause tempdb to
grow during a shrink.
"Rod Bautista" <rod.bautista@.cox.net> wrote in message
news:euzneqjqEHA.2340@.TK2MSFTNGP11.phx.gbl...
> I'm looking at all the possible issues that may have contributed to an
> inexplicably large jump in size for my tempdb. I recall reading an
article
> or posting that stated shrinking a user database will cause tempdb to
grow.
> Can anyone provide insight on this?
>
|||AFAIK, tempdb is not used for a shrink. The pages are quite simply moved toward the beginning of the
file.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Rod Bautista" <rod.bautista@.cox.net> wrote in message news:euzneqjqEHA.2340@.TK2MSFTNGP11.phx.gbl...
> I'm looking at all the possible issues that may have contributed to an
> inexplicably large jump in size for my tempdb. I recall reading an article
> or posting that stated shrinking a user database will cause tempdb to grow.
> Can anyone provide insight on this?
>
|||Thanks Adam and Tibor.
I thought as much...I was certain somebody stated that in a post and the
idea stuck with me. It didn't make any sense for temdb to be affected
during a shrink operation but I had to throw the question out there.
R
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:u$OUb8jqEHA.3464@.tk2msftngp13.phx.gbl...
> AFAIK, tempdb is not used for a shrink. The pages are quite simply moved
toward the beginning of the
> file.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Rod Bautista" <rod.bautista@.cox.net> wrote in message
news:euzneqjqEHA.2340@.TK2MSFTNGP11.phx.gbl...[vbcol=seagreen]
article[vbcol=seagreen]
grow.
>
|||I know others have replied with the same answer, but I'll also say that from
the code in shrink there's nothing that touches or affects tempdb.
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Rod Bautista" <rod.bautista@.cox.net> wrote in message
news:euzneqjqEHA.2340@.TK2MSFTNGP11.phx.gbl...
> I'm looking at all the possible issues that may have contributed to an
> inexplicably large jump in size for my tempdb. I recall reading an
article
> or posting that stated shrinking a user database will cause tempdb to
grow.
> Can anyone provide insight on this?
>

Thursday, March 22, 2012

does shrink database cause any blocking ?

Can dbcc shrinkdatabase be performed anytime and will this lead to
blocking,etc. ?There's absolutely no need to run this in single user mode or backup your
master database. The whole point of shrink is that you can run it online.
Shrink will take short term page X locks and table IX locks while it is
moving pages but should not cause any long-term blocking. It is setup so as
to always be picked as the deadlock victim, if a deadlock occurs. What you
may see is shrink itself being blocked for a long period as it will always
wait for the page locks it needs.
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.
"Steve Thompson" <SteveThompson@.nomail.please> wrote in message
news:uhMAa2rWDHA.1004@.TK2MSFTNGP12.phx.gbl...
> "Hassan" <fatima_ja@.hotmail.com> wrote in message
> news:eJ9m0srWDHA.1632@.TK2MSFTNGP11.phx.gbl...
> > Can dbcc shrinkdatabase be performed anytime and will this lead to
> > blocking,etc. ?
> >
> It might -- this operation is one I'd recommend running in single user
mode.
> Be sure to back up master and your application databases when complete.
> Steve
>

Wednesday, March 21, 2012

Does RAISERROR cause performance to go down slightly?

I was curious if using RAISERROR in the catch block of a stored procedure does actually causes some hit on performance? I think it would, as compared to simply returning an error code in this sp's output parameter.

It will cause some impact as RAISEERROR will inevitably require some extra resource, where as you rightly say an error code just requires a value to be set within an existing block of memory.

Friday, March 9, 2012

does dbcc updateusage cause blocking ?

does dbcc updateusage cause blocking ?Yes - it takes a table S lock for the duration of the operation so will
block all writes.
--
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:Ooty9JafFHA.3788@.tk2msftngp13.phx.gbl...
>

does dbcc updateusage cause blocking ?

does dbcc updateusage cause blocking ?Yes - it takes a table S lock for the duration of the operation so will
block all writes.
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:Ooty9JafFHA.3788@.tk2msftngp13.phx.gbl...
>

does dbcc updateusage cause blocking ?

does dbcc updateusage cause blocking ?Yes - it takes a table S lock for the duration of the operation so will
block all writes.
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:Ooty9JafFHA.3788@.tk2msftngp13.phx.gbl...
>

Does DBCC SHRINKFILE on a data file cause the log to grow?

We have 60GB free of a 140GB data file in one of our databases in SQL
Server 2000 SP2. I've truncated the free space at the end, but it won't
shrink any further now. I tried running DBCC SHRINKFILE, but had to
cancel it and run a log backup when the transaction log grew to 40GB and
started threatening the free disk space. Is this expected behaviour.
If it is, can anybody recommend a way to shrink the data file without
growing the log - e.g. do I have to temporarily change the database
model to simple, or something like that?
Cheers,
MalcMalcolm
Make a long story shortly
1)Perfom BACKUP LOG file ( it removes all inactive transaction )
2)Pefrom DBCC SHRINKFILE to reduce physical size of the log file.
"Malcolm Ferguson" <Malcolm_Ferguson@.NO_SPAM_PLEASEyahoo.com> wrote in
message news:ekOInAj9DHA.2472@.TK2MSFTNGP10.phx.gbl...
> We have 60GB free of a 140GB data file in one of our databases in SQL
> Server 2000 SP2. I've truncated the free space at the end, but it won't
> shrink any further now. I tried running DBCC SHRINKFILE, but had to
> cancel it and run a log backup when the transaction log grew to 40GB and
> started threatening the free disk space. Is this expected behaviour.
> If it is, can anybody recommend a way to shrink the data file without
> growing the log - e.g. do I have to temporarily change the database
> model to simple, or something like that?
> Cheers,
> Malc
>|||Sometimes, if this fails, you have to put some transactions into the
database to roll the virtual log to the beginning of the physical log. I've
had success with:
1) Backup the log
2) Run DBCC SHRINKFILE
3) If step 2 does not work, create a temp table in the database and add 1000
rows.
4) Delete the rows and the temp table. This will create t-log entries that
will force the virtual log to roll to the frony of the physical file (See
BOL for details on t-log architecture).
5) Backup the log.
6) Run DBCC SHRINKFILE again. It should work this time. If not, repeat
from 3.
The process is documented in a Q article somewhere for SQL 7. You are not
supposed to need it for SQL 2000 but I havbe found it comes in handy.
Christian Smith
"Malcolm Ferguson" <Malcolm_Ferguson@.NO_SPAM_PLEASEyahoo.com> wrote in
message news:ekOInAj9DHA.2472@.TK2MSFTNGP10.phx.gbl...
> We have 60GB free of a 140GB data file in one of our databases in SQL
> Server 2000 SP2. I've truncated the free space at the end, but it won't
> shrink any further now. I tried running DBCC SHRINKFILE, but had to
> cancel it and run a log backup when the transaction log grew to 40GB and
> started threatening the free disk space. Is this expected behaviour.
> If it is, can anybody recommend a way to shrink the data file without
> growing the log - e.g. do I have to temporarily change the database
> model to simple, or something like that?
> Cheers,
> Malc
>|||Yes this is expected behavior. When you shrink a data file it has to
physically move all data at the end of the file towards the beginning and
each move is fully logged. I would shrink in smaller increments and backup
the log after each one to keep it in check.
Andrew J. Kelly
SQL Server MVP
"Malcolm Ferguson" <Malcolm_Ferguson@.NO_SPAM_PLEASEyahoo.com> wrote in
message news:ekOInAj9DHA.2472@.TK2MSFTNGP10.phx.gbl...
> We have 60GB free of a 140GB data file in one of our databases in SQL
> Server 2000 SP2. I've truncated the free space at the end, but it won't
> shrink any further now. I tried running DBCC SHRINKFILE, but had to
> cancel it and run a log backup when the transaction log grew to 40GB and
> started threatening the free disk space. Is this expected behaviour.
> If it is, can anybody recommend a way to shrink the data file without
> growing the log - e.g. do I have to temporarily change the database
> model to simple, or something like that?
> Cheers,
> Malc
>|||Guys,
Thanks for the advice, but I'm not trying to shrink the log file. I'm
trying to shrink the *DATA* file. However, whenever I try this, the log
file starts growing like crazy.
Please advice further,
Malc
Christian Smith wrote:

>Sometimes, if this fails, you have to put some transactions into the
>database to roll the virtual log to the beginning of the physical log. I'v
e
>had success with:
>1) Backup the log
>2) Run DBCC SHRINKFILE
>3) If step 2 does not work, create a temp table in the database and add 100
0
>rows.
>4) Delete the rows and the temp table. This will create t-log entries tha
t
>will force the virtual log to roll to the frony of the physical file (See
>BOL for details on t-log architecture).
>5) Backup the log.
>6) Run DBCC SHRINKFILE again. It should work this time. If not, repeat
>from 3.
>The process is documented in a Q article somewhere for SQL 7. You are not
>supposed to need it for SQL 2000 but I havbe found it comes in handy.
>Christian Smith
>"Malcolm Ferguson" <Malcolm_Ferguson@.NO_SPAM_PLEASEyahoo.com> wrote in
>message news:ekOInAj9DHA.2472@.TK2MSFTNGP10.phx.gbl...
>
>
>|||Andrew J. Kelly wrote:

>Yes this is expected behavior. When you shrink a data file it has to
>physically move all data at the end of the file towards the beginning and
>each move is fully logged. I would shrink in smaller increments and backup
>the log after each one to keep it in check.
>
Andrew,
That's interesting. If I understand you correctly, when trying to
recover some of this 61,000MB of slack space, I should do the following:
DBCC SHRINKFILE (MyDb_Data, 140000)
-> Backup log
DBCC SHRINKFILE (MyDb_Data, 135000)
-> Backup log
DBCC ... etc.
rather than:
DBCC SHRINKFILE (MyDb_Data)
or
DBCC SHRINKFILE (MyDb_Data, 85000)
If I do this, you're saying it will consume less log space?
Cheers,
Malc|||yes. shrinking the data file(s) will fill up your log file. you could try
setting your recovery mode to simple before doing the shrinkfile. you'll st
ill
need some available space in your log file even with simple recovery.
Malcolm Ferguson wrote:

> Thanks for the advice, but I'm not trying to shrink the log file. I'm
> trying to shrink the *DATA* file. However, whenever I try this, the log
> file starts growing like crazy.|||What I am saying is it will allow you to control your log file by giving you
time to issue log backups in between the shrinks. That way your log file
won't grow on you. It also allows you to manage the process a bit better.
By the way you don't want to remove any where near all of your free space.
The database needs lots of free space to operate properly. The less free
space you have the more you risk fragmentating your tables when you reindex.
When you reindex a table you should ensure you have 1.2 to 1.5 times the
size of the table and indexes free and hopefully contiguous.
Andrew J. Kelly
SQL Server MVP
"Malcolm Ferguson" <Malcolm_Ferguson@.NO_SPAM_PLEASEyahoo.com> wrote in
message news:%23nlIL7j9DHA.3880@.TK2MSFTNGP11.phx.gbl...
> Andrew J. Kelly wrote:
>
backup
> Andrew,
> That's interesting. If I understand you correctly, when trying to
> recover some of this 61,000MB of slack space, I should do the following:
> DBCC SHRINKFILE (MyDb_Data, 140000)
> -> Backup log
> DBCC SHRINKFILE (MyDb_Data, 135000)
> -> Backup log
> DBCC ... etc.
> rather than:
> DBCC SHRINKFILE (MyDb_Data)
> or
> DBCC SHRINKFILE (MyDb_Data, 85000)
> If I do this, you're saying it will consume less log space?
> Cheers,
> Malc
>|||Andrew J. Kelly wrote:

>What I am saying is it will allow you to control your log file by giving yo
u
>time to issue log backups in between the shrinks. That way your log file
>won't grow on you. It also allows you to manage the process a bit better.
>By the way you don't want to remove any where near all of your free space.
>The database needs lots of free space to operate properly. The less free
>space you have the more you risk fragmentating your tables when you reindex
.
>When you reindex a table you should ensure you have 1.2 to 1.5 times the
>size of the table and indexes free and hopefully contiguous.
>
Thanks all for you help and advice. I was able to remove 20GB using the
suggestions, which leaves plenty of slack space in the datafile, and
leaves the free disk space at a sane level.
Cheers,
Malc

Does DBCC SHRINKFILE on a data file cause the log to grow?

We have 60GB free of a 140GB data file in one of our databases in SQL
Server 2000 SP2. I've truncated the free space at the end, but it won't
shrink any further now. I tried running DBCC SHRINKFILE, but had to
cancel it and run a log backup when the transaction log grew to 40GB and
started threatening the free disk space. Is this expected behaviour.
If it is, can anybody recommend a way to shrink the data file without
growing the log - e.g. do I have to temporarily change the database
model to simple, or something like that?
Cheers,
MalcMalcolm
Make a long story shortly
1)Perfom BACKUP LOG file ( it removes all inactive transaction )
2)Pefrom DBCC SHRINKFILE to reduce physical size of the log file.
"Malcolm Ferguson" <Malcolm_Ferguson@.NO_SPAM_PLEASEyahoo.com> wrote in
message news:ekOInAj9DHA.2472@.TK2MSFTNGP10.phx.gbl...
> We have 60GB free of a 140GB data file in one of our databases in SQL
> Server 2000 SP2. I've truncated the free space at the end, but it won't
> shrink any further now. I tried running DBCC SHRINKFILE, but had to
> cancel it and run a log backup when the transaction log grew to 40GB and
> started threatening the free disk space. Is this expected behaviour.
> If it is, can anybody recommend a way to shrink the data file without
> growing the log - e.g. do I have to temporarily change the database
> model to simple, or something like that?
> Cheers,
> Malc
>|||Sometimes, if this fails, you have to put some transactions into the
database to roll the virtual log to the beginning of the physical log. I've
had success with:
1) Backup the log
2) Run DBCC SHRINKFILE
3) If step 2 does not work, create a temp table in the database and add 1000
rows.
4) Delete the rows and the temp table. This will create t-log entries that
will force the virtual log to roll to the frony of the physical file (See
BOL for details on t-log architecture).
5) Backup the log.
6) Run DBCC SHRINKFILE again. It should work this time. If not, repeat
from 3.
The process is documented in a Q article somewhere for SQL 7. You are not
supposed to need it for SQL 2000 but I havbe found it comes in handy.
Christian Smith
"Malcolm Ferguson" <Malcolm_Ferguson@.NO_SPAM_PLEASEyahoo.com> wrote in
message news:ekOInAj9DHA.2472@.TK2MSFTNGP10.phx.gbl...
> We have 60GB free of a 140GB data file in one of our databases in SQL
> Server 2000 SP2. I've truncated the free space at the end, but it won't
> shrink any further now. I tried running DBCC SHRINKFILE, but had to
> cancel it and run a log backup when the transaction log grew to 40GB and
> started threatening the free disk space. Is this expected behaviour.
> If it is, can anybody recommend a way to shrink the data file without
> growing the log - e.g. do I have to temporarily change the database
> model to simple, or something like that?
> Cheers,
> Malc
>|||Yes this is expected behavior. When you shrink a data file it has to
physically move all data at the end of the file towards the beginning and
each move is fully logged. I would shrink in smaller increments and backup
the log after each one to keep it in check.
--
Andrew J. Kelly
SQL Server MVP
"Malcolm Ferguson" <Malcolm_Ferguson@.NO_SPAM_PLEASEyahoo.com> wrote in
message news:ekOInAj9DHA.2472@.TK2MSFTNGP10.phx.gbl...
> We have 60GB free of a 140GB data file in one of our databases in SQL
> Server 2000 SP2. I've truncated the free space at the end, but it won't
> shrink any further now. I tried running DBCC SHRINKFILE, but had to
> cancel it and run a log backup when the transaction log grew to 40GB and
> started threatening the free disk space. Is this expected behaviour.
> If it is, can anybody recommend a way to shrink the data file without
> growing the log - e.g. do I have to temporarily change the database
> model to simple, or something like that?
> Cheers,
> Malc
>|||Guys,
Thanks for the advice, but I'm not trying to shrink the log file. I'm
trying to shrink the *DATA* file. However, whenever I try this, the log
file starts growing like crazy.
Please advice further,
Malc
Christian Smith wrote:
>Sometimes, if this fails, you have to put some transactions into the
>database to roll the virtual log to the beginning of the physical log. I've
>had success with:
>1) Backup the log
>2) Run DBCC SHRINKFILE
>3) If step 2 does not work, create a temp table in the database and add 1000
>rows.
>4) Delete the rows and the temp table. This will create t-log entries that
>will force the virtual log to roll to the frony of the physical file (See
>BOL for details on t-log architecture).
>5) Backup the log.
>6) Run DBCC SHRINKFILE again. It should work this time. If not, repeat
>from 3.
>The process is documented in a Q article somewhere for SQL 7. You are not
>supposed to need it for SQL 2000 but I havbe found it comes in handy.
>Christian Smith
>"Malcolm Ferguson" <Malcolm_Ferguson@.NO_SPAM_PLEASEyahoo.com> wrote in
>message news:ekOInAj9DHA.2472@.TK2MSFTNGP10.phx.gbl...
>
>>We have 60GB free of a 140GB data file in one of our databases in SQL
>>Server 2000 SP2. I've truncated the free space at the end, but it won't
>>shrink any further now. I tried running DBCC SHRINKFILE, but had to
>>cancel it and run a log backup when the transaction log grew to 40GB and
>>started threatening the free disk space. Is this expected behaviour.
>>If it is, can anybody recommend a way to shrink the data file without
>>growing the log - e.g. do I have to temporarily change the database
>>model to simple, or something like that?
>>Cheers,
>>Malc
>>
>
>|||Andrew J. Kelly wrote:
>Yes this is expected behavior. When you shrink a data file it has to
>physically move all data at the end of the file towards the beginning and
>each move is fully logged. I would shrink in smaller increments and backup
>the log after each one to keep it in check.
>
Andrew,
That's interesting. If I understand you correctly, when trying to
recover some of this 61,000MB of slack space, I should do the following:
DBCC SHRINKFILE (MyDb_Data, 140000)
-> Backup log
DBCC SHRINKFILE (MyDb_Data, 135000)
-> Backup log
DBCC ... etc.
rather than:
DBCC SHRINKFILE (MyDb_Data)
or
DBCC SHRINKFILE (MyDb_Data, 85000)
If I do this, you're saying it will consume less log space?
Cheers,
Malc|||yes. shrinking the data file(s) will fill up your log file. you could try
setting your recovery mode to simple before doing the shrinkfile. you'll still
need some available space in your log file even with simple recovery.
Malcolm Ferguson wrote:
> Thanks for the advice, but I'm not trying to shrink the log file. I'm
> trying to shrink the *DATA* file. However, whenever I try this, the log
> file starts growing like crazy.|||What I am saying is it will allow you to control your log file by giving you
time to issue log backups in between the shrinks. That way your log file
won't grow on you. It also allows you to manage the process a bit better.
By the way you don't want to remove any where near all of your free space.
The database needs lots of free space to operate properly. The less free
space you have the more you risk fragmentating your tables when you reindex.
When you reindex a table you should ensure you have 1.2 to 1.5 times the
size of the table and indexes free and hopefully contiguous.
--
Andrew J. Kelly
SQL Server MVP
"Malcolm Ferguson" <Malcolm_Ferguson@.NO_SPAM_PLEASEyahoo.com> wrote in
message news:%23nlIL7j9DHA.3880@.TK2MSFTNGP11.phx.gbl...
> Andrew J. Kelly wrote:
> >Yes this is expected behavior. When you shrink a data file it has to
> >physically move all data at the end of the file towards the beginning and
> >each move is fully logged. I would shrink in smaller increments and
backup
> >the log after each one to keep it in check.
> >
> >
> Andrew,
> That's interesting. If I understand you correctly, when trying to
> recover some of this 61,000MB of slack space, I should do the following:
> DBCC SHRINKFILE (MyDb_Data, 140000)
> -> Backup log
> DBCC SHRINKFILE (MyDb_Data, 135000)
> -> Backup log
> DBCC ... etc.
> rather than:
> DBCC SHRINKFILE (MyDb_Data)
> or
> DBCC SHRINKFILE (MyDb_Data, 85000)
> If I do this, you're saying it will consume less log space?
> Cheers,
> Malc
>|||Andrew J. Kelly wrote:
>What I am saying is it will allow you to control your log file by giving you
>time to issue log backups in between the shrinks. That way your log file
>won't grow on you. It also allows you to manage the process a bit better.
>By the way you don't want to remove any where near all of your free space.
>The database needs lots of free space to operate properly. The less free
>space you have the more you risk fragmentating your tables when you reindex.
>When you reindex a table you should ensure you have 1.2 to 1.5 times the
>size of the table and indexes free and hopefully contiguous.
>
Thanks all for you help and advice. I was able to remove 20GB using the
suggestions, which leaves plenty of slack space in the datafile, and
leaves the free disk space at a sane level.
Cheers,
Malc

Sunday, February 26, 2012

Does adding a new column cause entire subscription to reinitialize?

Hello,
Some hopefully simple questions for the replication experts!
SQL Server 2000, transactional replication, one publisher, one
subscriber.
I have added a column to an article on the publisher and the publisher
is already published. Initially I tried to do this as follows:
sp_repladdcolumn@.source_object = 'tblA',
@.column = 'NewField',
@.typetext = 'int NULL',
@.publication_to_add = 'MyPublication',
@.force_reinit_subscription = 0
but this gave me an error message:
"Error 21381. Cannot add (drop) column to table 'tblA' because the
table belongs to publication(s) with an active updatable subscription.
Set @.force_reinit_subscription to 1 to force reinitialization"
I then re-ran the above with @.force_reinit_subscription=1. The command
worked and returned the message "subscription(s) reinitliazed" but the
new column hasn't appeared on the subscriber.
My questions are as follows:
1 - Do I have to re-run the Snapshot Agent?
2 - If I do re-run the Snapshot Agent, will it reinitialize all other
tables (and their data) or will it just add the new column?
3 - Is there a way I can view the reinitialization commands that are
queued at the publisher to see whether the queued command is to add the
new column or whether it is to reinitialize everything?
Thanks very much!
Pawel
For information: the snapshot agent ran in the evening. The snapshot
agent copied across the new field ALONG WITH all tables related to
'tblA', so it's just as well that I didn't kick it off manually during
the day.
I would still like to know if there is a way to view the commands which
the snapshot agent is due to execute. Does anyone know?
Thanks
Pawel
Pawel wrote:
> Hello,
> Some hopefully simple questions for the replication experts!
> SQL Server 2000, transactional replication, one publisher, one
> subscriber.
> I have added a column to an article on the publisher and the publisher
> is already published. Initially I tried to do this as follows:
> sp_repladdcolumn@.source_object = 'tblA',
> @.column = 'NewField',
> @.typetext = 'int NULL',
> @.publication_to_add = 'MyPublication',
> @.force_reinit_subscription = 0
> but this gave me an error message:
> "Error 21381. Cannot add (drop) column to table 'tblA' because the
> table belongs to publication(s) with an active updatable subscription.
> Set @.force_reinit_subscription to 1 to force reinitialization"
> I then re-ran the above with @.force_reinit_subscription=1. The command
> worked and returned the message "subscription(s) reinitliazed" but the
> new column hasn't appeared on the subscriber.
> My questions are as follows:
> 1 - Do I have to re-run the Snapshot Agent?
> 2 - If I do re-run the Snapshot Agent, will it reinitialize all other
> tables (and their data) or will it just add the new column?
> 3 - Is there a way I can view the reinitialization commands that are
> queued at the publisher to see whether the queued command is to add the
> new column or whether it is to reinitialize everything?
> Thanks very much!
> Pawel
|||Pawel,
as your test shows, if you are specifying @.force_reinit_subscription=1, the
snapshot will contain everything and if not, it won't. To see the commands
that the snapshot agent runs you can use sp_browsereplcmds. Also you can
look in the distribution working folder to see the actual files.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com
(recommended sql server 2000 replication book:
http://www.nwsu.com/0974973602p.html)
|||Paul,
Just to clarify, I don't think the snapshot contained everything. It
looks like it only contained the tables which have a relationship with
'tblA', not all the tables in the published database.
Thanks for the note about sp_browsereplcmds.
Pawel
Paul Ibison wrote:
> Pawel,
> as your test shows, if you are specifying @.force_reinit_subscription=1, the
> snapshot will contain everything and if not, it won't. To see the commands
> that the snapshot agent runs you can use sp_browsereplcmds. Also you can
> look in the distribution working folder to see the actual files.
> Cheers,
> Paul Ibison SQL Server MVP, www.replicationanswers.com
> (recommended sql server 2000 replication book:
> http://www.nwsu.com/0974973602p.html)