Basic Question: Do you have to restart the instance if you change database or log file growth

  • Jeff Moden - Thursday, November 22, 2018 1:56 PM

    bdkdavid - Wednesday, November 21, 2018 5:37 PM

    Hi Jeff and Sue,
    Yes the 13 TB file is the mdf file. I just started working with the database yesterday. The last batch had growned the data base from 11.5 TB to 13 TB which was on Monday. I have not had time to go into further analysis at this time. I am planning on adding a few ndf file to the system and migrating certain tables to them. Then shrink the database file. Maybe you guy's can evaluate my plan. First I have to talk with the programmers with the application. They will help me pick out certain large tables. that I will create a separate ndf file for each table in question.

    I will move those tables into those selected files and shrink the database file mdf.
    I am toying with either creating them in the same file group Primary or separting them in there own individual file group.
    I only want those tables in that particular file in question. I believe only the separate file groups would be an answer to that. This is a rough draft. Do you have any particular recommendations!

    Did I mention this is SQL Server 2014 running in 2012 compatibility mode:
    It is not instant file initialization enabled

    there are several problems:
    1. Approaching max file size both lun NetApp and database
    2. database file backups are taking longer than expected usually 15 hours now it is 24 hours (FULL)
    3. batches are runing during backup in process running slowly
    4. log file backup fails several times throughout the day
    5. logfile maxs out at 2TB several times. Stops Database:
    6. ran shrink log file had to place database in simple first:ran dbcc cmd: returned to full
    7. it is not idea but it was a quick fix.

    Before you get into all that, let's find out a very important point. 

    You say the last batch caused the file to grow so let's talk about the nature of your batches vs the rest of your file.  Is most of the rest of your file static?  In other words, once you load a batch and maybe make an update or two, do the rows for that batch become totally static after a month or two?

    I'm still looking for answers to my questions above.  The reason is to be able to solve the problems you're currently having including the possibility of over-running a LUN and the insane amount of time you spend backing up.  It'll also help with all the other problems even though you "only" have the Standard Edition running in the 2k12 compatibility mode.

    --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)

  • Here is the result for the query, I had to type 

    schemanametablenametype_descdata_compression_descrowcountstotalspacekbtotalspacembusedspacekbusedspacembunusedspacekbunusedspacemb
    dbotable1CLUSTEREDNONE806313384174494344170404.63169368600165399.02512574421646393.98
    dbotable2CLUSTEREDNONE467457873419467224409635.96417114624407338.5235260052026064.5
    dbotable3CLUSTEREDNONE117229400486287968474890.59484038224472693.58224974460313302.42
    dbotable4CLUSTEREDNONE92892280381154216372220.91379228720370340.55192549647273936.45
    dbotable5CLUSTEREDNONE113451550467851336456886.07466475024455542.02137631258025874.98
    dbotable6CLUSTEREDNONE263745352235592312230070.62226984376221664.43860793629227374.57
    dbotable7CLUSTEREDNONE3453991687397000872236.346600071264453.8279692969181797.18
    dbotable8CLUSTEREDNONE932736966904171267423.556266705661198.363746568569015.7
    dbotable9CLUSTEREDNONE2721098885749863256151.015169666450485.0258019687136843.98
    dbotable10CLUSTEREDNONE696533445191216850695.484658831245496.453238566443524.6
    dbotable11CLUSTEREDNONE138559024295790048288857.47290939128284120.24485092036689635.76
    dbotable12CLUSTEREDNONE151850700315012864307629.75310445584303169.52456728039073438.48
    dbotable13CLUSTEREDNONE271738808186076144181714.98183063984178773.42301216023080744.58
    dbotable14CLUSTEREDNONE806313384276857848270368.99274038024267615.26281982434339615.74
    dbotable15CLUSTEREDNONE154264540316818552309393.12314825704307446.98199284839294872.02
    dbotable16CLUSTEREDNONE667399046012784858718.65828879256922.6518390567459058.35
    dbotable17CLUSTEREDNONE316015762286605622330.132108558420591.3917804722837665.61
    dbotable18CLUSTEREDNONE857108161813663217711.551643161616046.517050162251032.5
    dbotable19CLUSTEREDNONE114860229445328092239.539278948090614.73166380011716045.27
    dbotable20CLUSTEREDNONE703244161482567214478.21333521613022.6714904561840186.33
    dbotable21CLUSTEREDNONE29483600314451552140675.34142716152139371.24133540017867072.76
    dbotable22CLUSTEREDNONE368338201094684010690.2796293929403.713174481358951.3
    dbotable23CLUSTEREDNONE119581500327813272320130.15326550264318896.74126300840657762.26
    dbotable24CLUSTEREDNONE2007891844318524842173.094203512841049.9311501205357106.07
    dbotable25CLUSTEREDNONE293499848124153744121243.89123033104120149.52112064015399068.48
    dbotable26CLUSTEREDNONE263745352222290112217080.19221284992216098.63100512027570165.38
    dbotable27CLUSTEREDNONE233650881604737615671.271506566414712.569817121991209.44
    dbotable28CLUSTEREDNONE26672090215982392210920.3215070712210029.9991168026787769.01
    dbotable29CLUSTEREDNONE2007891846881184067199.066792765666335.68841848535144.4
    dbotable30CLUSTEREDNONE123613199999514352976088.23998693032975285.19822320123964008.8
    dbotable31CLUSTEREDNONE23733954192313432187806.09191520504187031.7479292823852147.26
    dbotable32CLUSTEREDNONE161732900661402336645900.72660742136645255.9966020082030036.01
    dbotable33CLUSTEREDNONE51802528309442764.5921879202136.64643024351731.36
    dbotable34CLUSTEREDNONE21508555817371229601696409.1417365011601695801.91621800215444568.1
    dbotable35CLUSTEREDNONE1738542006043752859021.025983203258429.726054967496261.28
    dbotable36CLUSTEREDNONE38410769193428816188895.33192829816188310.375990002399091.63
    dbotable37CLUSTEREDNONE1724349209205168889894.239147665689332.6757503211417128.33
    dbotable38NONCLUSTEREDNONE1734273005073299249543.945016868048992.855643126292631.15
    dbotable39CLUSTEREDNONE1106815684804592046919.844749514446381.985507765959358.02
    dbotable40CLUSTEREDNONE33326000010163656899254.4610110172098732.1553484812605838.85
    dbotable41NONCLUSTEREDNONE857108162077346420286.592028888819813.374845762576869.63
    dbotable42NONCLUSTEREDNONE1748943005113552049937.035065868049471.374768406342468.63
    dbotable43NONCLUSTEREDNONE467457873175229200171122.27174753424170657.6447577621732992.36
    dbotable44NONCLUSTEREDNONE703244161703923216639.881658272016194.064565122113709.94
    dbotable45NONCLUSTEREDNONE1753422005094351249749.525049603249312.534474806318626.47
    dbotable46NONCLUSTEREDNONE294831339149404072145902.41148961960145470.6644211218530038.34
    dbotable47CLUSTEREDNONE3392165529130916089169.19088824088757.0542092011324886.95
    dbotable48NONCLUSTEREDNONE1766073005134861650145.135093676049742.934118566368834.07
    dbotable49CLUSTEREDNONE1738542003087242430148.853047382429759.593986003829293.41
    dbotable50CLUSTEREDNONE80196900648392912633196.2647999432632811.9539348080416302.05
  • Maybe if I ask a third time... 😉
    You say the last batch caused the file to grow so let's talk about the nature of your batches vs the rest of your file. Is most of the rest of your file static? In other words, once you load a batch and maybe make an update or two, do the rows for that batch become totally static after a month or two?

    --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)

  • Hi Jeff, and frederico,

    This is functionally as a DW. 
    I do not do the batches. I was told they keep them no more than 75000 records.
    The batched are run with csv files mostly numbers, dates and nvarchar data.
    They load with bulk insert statements. 
    The Database is used for Data Analysis of the data.
    They load data 3 times per week between 30 and 350 GB of data.
    Yes, data is static. The do some kind of ETL. I have not had time to check that at this time.

    What i have down on this server to date.
    I created seven additional temp data files total 8
    I added two addtional data files to the primary file group. The data base stopped working.
    it ran out of space on the lun
    I intended to set to enable  instant file initialization. I have to do that latter this week
    The mdf  is still about 13 TB in size.

    There are so many problems here.
    What i am attempting to do is apply some best practices.
    What I would like to do is create several file groups and port all the data into those.
    spreading them between seveal files

    I thought about adding a couple more files the the primary filegroup
    and run DBCC SHRINKFILE ('database_name', EMPTYFILE);
    It should spread the file between the other files. I am not ssre that it will continue to use the mdf or not.
    that is another question!

    They are backing up all the databases together it takes about 24 hours plus used to take 15 hours
    I am attempting to separate this one from all the others.
    The log file needs to be shrink every week or so.
    The error is waiting for log file to be backed up.
    I am hoping that making the files smaller would increase the speed of the backup. 🙂

    the query that I used by frederico was unusedspacekb, it is a little out of order the first five I typed in.
    The others are in that sequence

    thank you Guy's,
    David

  • You're on the right track with separate files and file groups. 

    If the data is static after being loaded, then base your files and file groups so that...
    1.  You have one month of data per file.
    2.  You have only one file per filegroup.  The filegroup name should include YYYYMM as a part of the name for easy management.
    3.  Setup each table in each file with the proper constraint to support a partitioned view (NOT partitioned table)
    4.  Rebuild the indexes to 100% FILL FACTOR.  You no longer have to worry about page splits so 100% will help save space.
         You may have to rebuild the largest index on a temporary file group, shrink/rebuild all the other indexes, and then rebuild the largest index
         back onto the original file group.  That would keep you from blowing out the MDF file and that will prevent you from setting a whole lot of free space to READ_ONLY.
    5.  Set all filegroups but the current (which is not empty) and next month (which is empty) to READ_ONLY and back them up one final time. 
         You shouldn't have to back them up ever again.
    6.  Build your partitioned views across the tables in the various files so that they can be referenced as a single object whose name will not change.

    All of that has a bunch of different advantages as stated above but the biggest thing is that your backup durations will seriously decrease because you'll 
    only be backing up the current month (not empty) and the next month (because it's not read_only but is empty so not much action).

    --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)

  • After you've done that, automate the creation of a new file/filegroup for a new "next" month and the auto-magic rebuild of the partitioned view.

    Another cool part is that, if sometime in the future they want to start dropping off the old months, it'll be a cinch.

    --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)

  • on top of what Jeff said - I would strongly consider upgrading to SQL 2016 SP1 Standard (or 2017 Standard).
    with this upgrade you would get
    - table and index Partitioning
    - table compression
    - use of 24 cores instead of the 16 you can use now 
    - column store (Could be of interest here)

    You could probably check what would be the final benefits of compression on this db by setting up a Developer instance on another machine and copying a subset of data onto tables with compression enabled.

    What Jeff said would still apply except for the partitioned view aspect

  • To be honest, I actually prefer Paritioned Views over Partitioned Tables.  Try restoring just 3 months of a Partitioned Table to another server sometime and you'll
    see what I mean.

    Also, the nature of a partition can change just because the data becomes static in the older months.  That also means that the index requirements can change. 
    Try to put different indexes on different partitions to support that notion and still be able to do a SWITCH.  😉  The non-aligned indexes that you must use to do
    such a thing aren't aren't going to let you do SWITCH.  You might be able to use a filtered index but it will need to be maintained every time you roll and old partition
    into the world of "static" data.

    --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)

  • Thank Guy's 

    This is going to take me some time to implement. I will let everyone know what happens.
    Thanks,
    David

Viewing 9 posts - 16 through 23 (of 23 total)

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