Subject | Question about trigger performance |
---|---|
Author | fabiano_bonin |
Post date | 2003-03-12T22:30:19Z |
Let's suppose i have a trigger that verifies the integrity of the
inserted data.
For example, TABLE1 have one before insert trigger that verify some
other tables (see FORM 1 below) to see if data is consistent.
Will i loss performance if, instead of having one trigger that
verify all tables, i have various triggers, each one verifying 1
table (see FORM 2 below)?
If yes, will there be a big loss of performance?
Thanks.
--- FORM 1 ---
create trigger t1 on table1
after insert
as
begin
if ( exists ( select * from table1 where ... ) then ...
if ( exists ( select * from table2 where ... ) then ...
end;
--- FORM 2 ---
create trigger t1 on table1
after insert
as
begin
if ( exists ( select * from table1 where ... ) then ...
end;
create trigger t2 on table1
after insert
as
begin
if ( exists ( select * from table2 where ... ) then ...
end;
inserted data.
For example, TABLE1 have one before insert trigger that verify some
other tables (see FORM 1 below) to see if data is consistent.
Will i loss performance if, instead of having one trigger that
verify all tables, i have various triggers, each one verifying 1
table (see FORM 2 below)?
If yes, will there be a big loss of performance?
Thanks.
--- FORM 1 ---
create trigger t1 on table1
after insert
as
begin
if ( exists ( select * from table1 where ... ) then ...
if ( exists ( select * from table2 where ... ) then ...
end;
--- FORM 2 ---
create trigger t1 on table1
after insert
as
begin
if ( exists ( select * from table1 where ... ) then ...
end;
create trigger t2 on table1
after insert
as
begin
if ( exists ( select * from table2 where ... ) then ...
end;