Usage of Temprory Table in Stored Procedure

  • Dear All,

    For my project salary calculation writtened in Stored Proceure based.There is nearly 50 stored Procedure to Calculate different kind of Calculations.Some of the Stored Proceure Temprory tables used to do intermediate calculation and finally pushed to maintable.

    Is more usage of Temprory table degrade the performance.For the every used Temprory tables proper indexing done.We noticed that Temprory Database some pressure is there while executing the process.Can i convert the Temprory table to Static intermediate table.Kindly give your views.

    Regards

    Siva

  • You may create constraints and indexes on temporary tables. I think you would benefit by having a regular table; that way you could depend on constraints and indexes and possibly updated statistics always being there. There are global and local temp tables depending on a declaration like #tbl or ##tbl and the local ones are cleaned up when a connection is closed. I find that there is overhead in using global objects accessible outside of a connection. Temp tables cause contention in sysobjects which might be a problem if you are often creating and dropping them.

    Table variables within a stored procedure perform very well if there are less than thousands of rows and they benefit from constraints.

    You may need to play around with your unique situation to find out empirically what works best.

  • Any additonal line of code (excluding comments) degrades the performance less or more...

    There is nothing wrong with using temp tables.

    Using static (permanent) tables, global temp tables and/or table variables will not avoide using tempdb, which whould be properly managed by DBA's (yes queries using just and only permanent tables also might use tempdb).

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

Viewing 3 posts - 1 through 2 (of 2 total)

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