sql - Multiple inserts to temp table followed by single insert to material table OR multiple inserts straight to material table -


i've got query structured follows:

create temptable ... insert temptable ... insert temptable ... insert temptable ... insert materialtable select * temptable 

would more efficient avoid using temporary table , several inserts straight material table? i.e.

insert materialtable ... insert materialtable ... insert materialtable 

the answer depends on exact structure of destination table , indexes, , on nature of processes access materialtable concurrently insertion.

  • temptable has no indexes; materialtable have several indexes. depending on amount of data being inserted , number of individual inserts, copying temp faster, because single multi-row check of each index needs performed.
  • temptable invisible outsiders; materialtable accessed concurrently program. in cases that, amount of locking , unlocking smaller.
  • inserting rows @ once offers better chance parallelize insertion possibly faster insert.

none of matter if materialtable small (a few thousand rows). larger tables impact more significant, recommend keeping temp table approach when materialtable expected large.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -