select @@identity / scope_identity() takes 1 second?

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
Reaction score
13
I have a big table that I partitioned, 7million records. To write in a record takes less than 2ms. But I need the new ID on the identity field to populate the other tables related to the big one. So I use select @id = scope_identity() (or @@identity) from mytable

That select takes longer than the entire stored procedure runs for 1 record (and I insert/update at least 8 other tables)

Is there anything I can do to speed this up?? (nb, it looks like when I partitioned the table it removed the clustered index from the PK to the column I used for the partitioning)
 
I just did an experiment. Instead of select @id = scope_identity() I did select @id = id from table where detailsI'mworkingwith = @detailsI'mworking with and now I'm doing 30+ records per second
 
Top
Sign up to the MyBroadband newsletter
X