Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7018849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:06:19+00:00 2026-05-27T23:06:19+00:00

Most of our tables have one BEFORE INSERT OR UPDATE trigger, in order to

  • 0

Most of our tables have one BEFORE INSERT OR UPDATE trigger, in order to set ID’s BEFORE INSERT and to set creation / modification users / dates BEFORE INSERT OR UPDATE.

There are a couple of tables with additional triggers, which were separated from the previous one in order to make their intent more clear. Also, those additional triggers could be disabled independently from the previous one, which should never be disabled.

In most cases, the additional triggers also fire BEFORE INSERT OR UPDATE and the order is unimportant, as they cover different columns / use-cases. So generally, they could be combined to single triggers.

Are there any studies about the speed of calling 1 or n triggers on a table? Or is that pretty much irrelevant for single-row inserts / updates? In other words, is there only 1 global SQL -> PL/SQL context switch, or will there be 1 context switch per trigger.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:06:20+00:00Added an answer on May 27, 2026 at 11:06 pm

    I have now benchmarked this situation and I came to the conclusion that there is a significant performance loss most likely due to PL/SQL context switches, when adding 1 trigger. The loss is by factor 8 in my benchmark. Adding a second “compatible” trigger, however, doesn’t have any significant impact anymore. By “compatible”, I mean both triggers always fire at the same event in any order.

    So I’m concluding that there is most likely only 1 SQL -> PL/SQL context switch for all triggers


    Here’s the benchmark:

    Create a table

    -- A typical table with primary key, creation/modification user/date, and 
    -- other data columns
    CREATE TABLE test(
      id number(38)    not null, -- pk
      uc varchar2(400) not null, -- creation user
      dc date          not null, -- creation date
      um varchar2(400),          -- modification user
      dm date,                   -- modification date
      data number(38)
    );
    

    … and a sequence

    CREATE SEQUENCE s_test;
    

    A typical trigger setting ID, creation/modification user/date

    CREATE OR REPLACE TRIGGER t_test BEFORE INSERT OR UPDATE
      ON test
      FOR EACH ROW
    BEGIN
      IF inserting THEN
        SELECT s_test.nextval INTO :new.id FROM dual;
    
        :new.uc := USER;
        :new.dc := SYSDATE;
        :new.um := NULL;
        :new.dm := NULL;
      END IF;
      IF updating THEN
        :new.um := USER;
        :new.dm := SYSDATE;
        :new.uc := :old.uc;
        :new.dc := :old.dc;
      END IF;
    END t_test;
    

    Insert 1000, 10000, 100000 Records

    declare
      procedure run (limit number) is
        t timestamp;
      begin
        t := systimestamp;
    
        insert into test (data)
        select level from dual connect by level < limit;
    
        dbms_output.put_line(to_char(systimestamp - t));
    
        rollback;
      end;
    begin
      run(1000);
      run(10000);
      run(100000);
    end;
    

    Results

    -- ------------------------------------
    -- +000000000 00:00:00.086603000
    -- +000000000 00:00:00.844333000
    -- +000000000 00:00:08.429186000
    -- ------------------------------------
    

    Another “compatible” trigger (execution order irrelevant)

    CREATE OR REPLACE TRIGGER t_test_other BEFORE INSERT OR UPDATE
      ON test
      FOR EACH ROW
    BEGIN
      :new.data := 42;
    END t_test_other;
    

    Results of another run of the test script

    -- ------------------------------------
    -- +000000000 00:00:00.088551000
    -- +000000000 00:00:00.876028000
    -- +000000000 00:00:08.731345000
    -- ------------------------------------
    

    Deactivate triggers

    alter trigger t_test disable;
    alter trigger t_test_other disable;
    

    Run a slightly different test script

    declare
      procedure run (limit number) is
        t timestamp;
      begin
        t := systimestamp;
    
        insert into test (id, uc, dc, data)
        select s_test.nextval, user, sysdate, level from dual 
        connect by level < limit;
    
        dbms_output.put_line(to_char(systimestamp - t));
    
        rollback;
      end;
    begin
      run(1000);
      run(10000);
      run(100000);
    end;
    

    Results

    -- ------------------------------------
    -- +000000000 00:00:00.012712000
    -- +000000000 00:00:00.104903000
    -- +000000000 00:00:01.043984000
    -- ------------------------------------
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a poorly designed database. One of the most important tables has 11,000+
Most of our Eclipse projects have multiple source folders, for example: src/main/java src/test/java When
I have for the most part successfully embedded firefox/xulrunner into our c# application, but
One of our MSI's has started failing with Error 2902. It'll get most of
Page in question: http://phwsinc.com/our-work/one-rincon-hill.asp In IE6-8, when you click the left-most thumbnail in the
I have two tables of concern here: users and race_weeks. User has many race_weeks,
I have one of the most frustuating problems i have ever had with a
I have three tables called: users , facilities , and staff_facilities . users contains
We have three tables to hold our products and keywords: Product {int ID, string
Tables have been created in our SQL Server 2008 R2 database on a local server,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.