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.
temptablehas no indexes;materialtablehave 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.temptableinvisible outsiders;materialtableaccessed 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
Post a Comment