Tempdb growth

  • Hi,

    I have a huge insert/update operation performing in set of tables. The process tooks almost 1-2 hours to complete. Meanwhile tempdb is growing fast and most of my applications using the sql server gets hung during that time.

    To overcome this Replacing the stored procedure with SSIS will help in my scenario???

    Please share your valuable inputs. Thanks in advance!

    Chelladurai

  • haichells - Monday, December 25, 2017 10:14 PM

    Hi,

    I have a huge insert/update operation performing in set of tables. The process tooks almost 1-2 hours to complete. Meanwhile tempdb is growing fast and most of my applications using the sql server gets hung during that time.

    To overcome this Replacing the stored procedure with SSIS will help in my scenario???

    Please share your valuable inputs. Thanks in advance!

    Chelladurai

    No.  It won't help if you do similar as to what you did in the stored procedure.  What needs to happen is you need to step back and look at the code.  Code that blows out TempDB is a very strong indication that you have some accidental many-to-many joins and you need to fix that problem no matter what you use.

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

  • The accidental many-to-many join that Jeff mentioned is a possibility.  So is an implicit cast that required you to read an entire table is another, but there are others.  Take a look at your query plan and look for the yellow triangle icon on one of your steps.  Mouseover the icon and look for the warning near the bottom of the tooltip.

  • Is it possible you are returning a very (unneccessarily) large result set that is being stored in TempDB as part of a single transaction before being filtered and sorted?  Is your transaction log similarly bloated?

    If that is the case try breaking down the transaction into smaller more manageble transactions.

    Also, if other applications are affected as a result of file contention (as I assume it might be) try adding more files to TempDB.  You will need to look in the logfiles to see if this is happening. 

    If you decide to add more files, have a look at this first:
    https://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-1230-tempdb-should-always-have-one-data-file-per-processor-core/

    As mentioned in the link, trace flag 1118 could help mitigate some problems if you haven't already turned it on and aren't already on SQL Server 2016.

    Is it possible for you to post the stored procedure code so we can have a look at it?

  • kevaburg - Tuesday, December 26, 2017 6:33 AM

    Is it possible you are returning a very (unneccessarily) large result set that is being stored in TempDB as part of a single transaction before being filtered and sorted?  Is your transaction log similarly bloated?

    If that is the case try breaking down the transaction into smaller more manageble transactions.

    Also, if other applications are affected as a result of file contention (as I assume it might be) try adding more files to TempDB.  You will need to look in the logfiles to see if this is happening. 

    If you decide to add more files, have a look at this first:
    https://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-1230-tempdb-should-always-have-one-data-file-per-processor-core/

    As mentioned in the link, trace flag 1118 could help mitigate some problems if you haven't already turned it on and aren't already on SQL Server 2016.

    Is it possible for you to post the stored procedure code so we can have a look at it?

    For SQL Server 2016 and up, you have no real choice... Trace Flag 1118 is on whether you want it to be or not.

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

  • Jeff Moden - Tuesday, December 26, 2017 6:55 AM

    kevaburg - Tuesday, December 26, 2017 6:33 AM

    Is it possible you are returning a very (unneccessarily) large result set that is being stored in TempDB as part of a single transaction before being filtered and sorted?  Is your transaction log similarly bloated?

    If that is the case try breaking down the transaction into smaller more manageble transactions.

    Also, if other applications are affected as a result of file contention (as I assume it might be) try adding more files to TempDB.  You will need to look in the logfiles to see if this is happening. 

    If you decide to add more files, have a look at this first:
    https://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-1230-tempdb-should-always-have-one-data-file-per-processor-core/

    As mentioned in the link, trace flag 1118 could help mitigate some problems if you haven't already turned it on and aren't already on SQL Server 2016.

    Is it possible for you to post the stored procedure code so we can have a look at it?

    For SQL Server 2016 and up, you have no real choice... Trace Flag 1118 is on whether you want it to be or not.

    I only mentioned it because the OP hasn't mentioned what SQL Server version he is using....

  • kevaburg - Tuesday, December 26, 2017 9:25 AM

    Jeff Moden - Tuesday, December 26, 2017 6:55 AM

    kevaburg - Tuesday, December 26, 2017 6:33 AM

    Is it possible you are returning a very (unneccessarily) large result set that is being stored in TempDB as part of a single transaction before being filtered and sorted?  Is your transaction log similarly bloated?

    If that is the case try breaking down the transaction into smaller more manageble transactions.

    Also, if other applications are affected as a result of file contention (as I assume it might be) try adding more files to TempDB.  You will need to look in the logfiles to see if this is happening. 

    If you decide to add more files, have a look at this first:
    https://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-1230-tempdb-should-always-have-one-data-file-per-processor-core/

    As mentioned in the link, trace flag 1118 could help mitigate some problems if you haven't already turned it on and aren't already on SQL Server 2016.

    Is it possible for you to post the stored procedure code so we can have a look at it?

    For SQL Server 2016 and up, you have no real choice... Trace Flag 1118 is on whether you want it to be or not.

    I only mentioned it because the OP hasn't mentioned what SQL Server version he is using....

    Understood and very much appreciated.  I made the probable bad assumption that the OP posted in a 2017 forum because that's what he was using.  That's frequently a really bad assumption as we've seen so often in the past.

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

  • Dear All,

    Thanks a lot for your ideas! I will try to refine the sql statements also i will check the plan and if i need any help i will get back to you. Thanks again!

    Chelladurai

  • haichells - Tuesday, December 26, 2017 9:52 PM

    Dear All,

    Thanks a lot for your ideas! I will try to refine the sql statements also i will check the plan and if i need any help i will get back to you. Thanks again!

    Chelladurai

    If you want, we might be able to help a bit if you posted the stored procedures (to start with) as attachments (txt file).

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

  • This was removed by the editor as SPAM

  • If tempdb data and log files had been inflated by your previous operation, what would happen now if you repeat it now?  Was it tempdb log file that was growing or it happened to its data file as well?
    Is Instant File Initialization turned on? (this would only affect tempdb data file)
    Are you prepared to monitor tempdb log file usage as the operation is in progress next time?

  • This was removed by the editor as SPAM

Viewing 12 posts - 1 through 11 (of 11 total)

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