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 8697609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:34:06+00:00 2026-06-13T01:34:06+00:00

If we have a sequence to generate unique ID fields for a table, which

  • 0

If we have a sequence to generate unique ID fields for a table, which of the 2 approaches is more efficient:

  1. Create a trigger on insert, to populate the ID field by fetching nextval from sequence.
  2. Calling nextval on the sequence in the application layer before inserting the object (or tuple) in the db.

EDIT: The application performs a mass upload. So assume thousands or a few millions of rows to be inserted each time the app runs. Would triggers from #1 be more efficient than calling the sequence within the app as mentioned in #2?

  • 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-06-13T01:34:07+00:00Added an answer on June 13, 2026 at 1:34 am

    Since you are inserting a large number of rows, the most efficient approach would be to include the sequence.nextval as part of the SQL statement itself, i.e.

    INSERT INTO table_name( table_id, <<other columns>> )
      VALUES( sequence_name.nextval, <<bind variables>> )
    

    or

    INSERT INTO table_name( table_id, <<other columns>> )
      SELECT sequence_name.nextval, <<other values>>
        FROM some_other_table
    

    If you use a trigger, you will force a context shift from the SQL engine to the PL/SQL engine (and back again) for every row you insert. If you get the nextval separately, you’ll force an additional round-trip to the database server for every row. Neither of these are particularly costly if you do them once or twice. If you do them millions of times, though, the milliseconds add up to real time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sequence which varies in length e.g. something like: items <- 1:4
I have the next sequence: create activity; place a fragment into it; go to
I have an table (in ORADB) containing two columns: VARCHAR unique key and NUMBER
I am using Generate Sequence Diagram feature of Visual Studio. I have to show
how to Generate a unique sequence ID to be stored in unsigned long ?
I need to generate Sequence Diagram for my project. I have made the classes,
I have been using the svgwrite library to generate a sequence of svg images.
I am using UMLGraph to generate sequence diagrams. I have a problem using the
Problem: I need to generate the following sequence. I have the order of the
I have a table of items, each of which has a date associated with

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.