Camillia
asked on
Are triggers slow?
"Are triggers slow?" is a general question that I know depends on what the trigger is doing.
This is sq 2014.
We're importing more than 50,000 rows of data. Some calculation needs to be done on the data to calculate the ranking and some other data and then insert the data in a table. He wants to use triggers.
Do triggers in SQ Server are row by row processing? Would triggers be slow in the case above?
I suggested dumping the data in a table. Write a stored proc. Calculate data and then dump the data in the main table.
This is sq 2014.
We're importing more than 50,000 rows of data. Some calculation needs to be done on the data to calculate the ranking and some other data and then insert the data in a table. He wants to use triggers.
Do triggers in SQ Server are row by row processing? Would triggers be slow in the case above?
I suggested dumping the data in a table. Write a stored proc. Calculate data and then dump the data in the main table.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>I thought it does one by one row operation.
This is exactly what it does. Every row affected will execute the trigger
This is exactly what it does. Every row affected will execute the trigger
ASKER
thanks, Eric.
I thought it does one by one row operation.No, it doesn't. If only runs once for all rows that you've inserted, deleted or updated. You can confirm that by query the respective tables: inserted or deleted
your right Vitor. This is why the inserted and deleted tables inherent to the triggers can contain multiple rows. I don't know why, I have mixed Triggers and UDF!
ASKER
thanks
ASKER