SQL Server - Stored procedures slow vs "Giant" script -
i have large number of stored procedures (about 200) need executed sequentially. ideally wanted create single "master" stored procedure execute each of individual stored procedures 1 after another.
however, when execute master stored procedure consistently freezes after running long time. being said, if take sql code 200 individual stored procedures , create 1 giant sql script file, runs without issue.
the sql code queries separate tables , inserts subset of data master "summary" table.
any ideas why happen? there stored procedures take more memory? prefer keep in stored procedures manage security , updates easier.
any ideas why happen?
compilation.
the master script compiled batch batch using statistics valid @ point.
the sp compiled once @ start, , if statistics change during run - typial sequence of loads - there go. if statistical change significant during processing. stats @ teh beginning - when things compiled - totally off compared runtime stats tables.
there recompile option can se tin individual statements avoid this.
Comments
Post a Comment