Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Usage of Temprory Table in Stored Procedure Expand / Collapse
Author
Message
Posted Thursday, February 6, 2014 5:32 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Sunday, September 21, 2014 11:35 PM
Points: 14, Visits: 91
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
Post #1538590
Posted Thursday, February 6, 2014 6:01 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 12:06 PM
Points: 156, Visits: 977
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.
Post #1538606
Posted Thursday, February 6, 2014 6:41 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, December 12, 2014 10:09 AM
Points: 2,876, Visits: 5,201
[quote
Is more usage of Temprory table degrade the performance.
...
[/quote]

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!"
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Post #1538627
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse