• homebrew01 (12/24/2013)


    Thanks.

    It is a table in an archive database that is in simple recovery mode.

    The index itself is 1 or 2 gig. The database has 2 files (mdf & ndf), I think on 2 different drives. I think each drive has 40 or 50 gig free. (We have an internet outage locally, so I can't log in)

    The recovery mode probably won't matter because, unless the table is partitioned, a rebuild is (IIRC) a single transaction that will be stored in the logfile until the transaction is complete.

    The MDF/LDF file will also grow, perhaps unacceptably, because for any rebuild over 128 extents, it builds a separate copy of the CI (and, therefor, a copy of the table itself) and only flops over to the new copy when the transaction completes.

    Serendipitously, I've recently created a way to be able to release all of that extra free space if the table lives in its own FileGroup. It's fairly complicated and requires a bit of offline time (the time it takes to rebuild the CI) and works best if the PRIMARY FileGroup of the Archive Database is mostly empty and has no tables in it. That would also require a little up front work because, to recover the space using the method, the PRIMARY FileGroup Files would need to be shrunk and we all know what that does to fragmentation levels of any tables it they contain. That means that any tables in the PRIMARY FileGroup should probably be moved to their own FileGroups and Files.

    Still, it might not be worth it for this (it was worth it to me because of the Partitioning that I'm doing to huge, mostly static, "insert only" audit tables) unless you need to keep the restore footprint as small as possible to be able to do restores to smaller machines. I say that because the drives for your problem are dedicated to the archive database, so let them be dedicated. Free space isn't backed up to tape.

    Of course, consideration for any of this would be a totally unnecessary exercise if MS actually did index rebuilds and file shrinks in an ages-old Peter Norton style instead of the current methods, which they do't seem interested in fixing.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)