Creating a Primary Key on a temp table - When?

后端 未结 9 682
一个人的身影
一个人的身影 2020-12-29 04:16

I have a stored procedure that is working with a large amount of data. I have that data being inserted in to a temp table. The overall flow of events is something like

9条回答
  •  猫巷女王i
    2020-12-29 04:42

    I don't think it makes any significant difference in your case:

    • either you pay the penalty a little bit at a time, with each single insert
    • or you'll pay a larger penalty after all the inserts are done, but only once

    When you create it up front before the inserts start, you could potentially catch PK violations as the data is being inserted, if the PK value isn't system-created.

    But other than that - no big difference, really.

    Marc

提交回复
热议问题