transactional log

  • If i need to truncate/shrink the transaction log file :

    can I use dbcc shrinkdatabase(' ',truncateonly) instead of using dbcc shrinkfile(2,truncateonly).earlier I was using the 2nd option dbcc shrinkfile but had to do full backup after this.

    If i do use shrinkdatabase cmd i think no need to take full backup.is it safe to use 'dbcc shrinkdatabase' rather than using 'dbcc shrinkfile' .Please advice me.

    Thanks,

    Litu

  • In my openion both command do the same thing one shrinkfile will shrink single file while shrinkdatabase will shrink the set of files in the database. Also after executing any shrink command no need to do the full backup but on saffer side you can do it.

    Also shrink command won't do any blocking or hold locks(Might be temporarily it can). BUT SHRINK COMMAND IS RESOURCE CONSUMING AND CONSUMES RESOURCES (CPU - MEMORY) OF THE SERVER HENCE ADVISABLE TO EXECUTE ON THE OFF-PICK HOURS.

    ---------------------------------------------------
    "Thare are only 10 types of people in the world:
    Those who understand binary, and those who don't."

  • You do not want to shrink the database. It causes fragmentation and messes with the index efficiency. If you need to shrink the log, shrink those files only.

  • Also note that truncating a log (removing inactive log entries) and shrinking the log (reducing the size on disk) are two separate things.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks it is really helpful information for me.

    I have one more query:

    If i shrink the whole database how caome it is possible to

    shrink the main database(except log file).

    Thnks,

    Litu

  • Are you asking how to shink the database and not the log? You'd do it by shrinking each of the data files individually.

    Note Steve's warning above. You don't want to shrink the database down, unless there's a good reason. See this link[/url], and also check out the two links at the bottom of that article

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I know how to shrink whole database and also individual file.

    I would like to know if i shrink only the database what would be the impact

    on database.how come it reduce the size of database.

    Thnks,

    Litu

  • litu deb (2/1/2008)


    I know how to shrink whole database and also individual file.

    DBCC shrink database to shrink the whole database. DBCC ShrinkFile to shrink individual files

    I would like to know if i shrink only the database what would be the impact

    on database.

    See Steve's comments, see the blog post I linked to, and be sure to check the links at the end of that. (to Paul randal's blog and the storage engine team's blog) Between them, they cover all the issues quite nicely

    how come it reduce the size of database.

    It only reduces the size of the DB if there's unused space in the data or log files. Shrink releases that space to the OS, so the file size decreases.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I understand used and free space in database.but what do you mean by unused space in database.

    thnks,

    Litu Deb

  • Unused = free

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply