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

  • Home
  • SEARCH
  • 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 6104471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:50:45+00:00 2026-05-23T13:50:45+00:00

I have a raw table used as a kind of buffer where periodically new

  • 0

I have a raw table used as a kind of buffer where periodically new data is inserted (average of ~20.000 rows inserted in bulk each ~5 minutes). Then there is a stored PL/SQL proceudre which reads this raw table and insert the information in the distinct tables of the database.
Unfortunately I cannot do a direct bulk insert in my destination table from the rows stored in the raw table, because part of the columns (10 out of 20) are foreign keys in the destination table. This means that before doing the insert I have to resolve all the foreign key id’s and then use these to insert the new rows in the destination table.
Moreover, the element in the foreign key table could not be there, so it needs to be inserted in the foreign key table and then its id can be used as foreign key id.

The solution I am going to use is to have a stored procedure that:
1) for each column of the raw table that corresponds to a foreign key in the destination table I select the distinct values of the column and for each one I select the id in the foreign table, and if it doesn’t exists I insert it reutrning the relative id;
2) I write out to an empty temporary table (truncated each time before inserting into it) the same rows of the raw table but with the resolved foreign keys;
3) I do a bulk insert in the destination table by selecting the values from the temporary table.

Why using a temporary table? Because I want to avoid to insert row by row in a destination table that has more then 50milions of lines.

(I have inerithed the oracle sql schema, and part of the solution structure; I cannot even change it since there is a uge set of monitoring tools that at the moment cannot be changed).

How can I optimize the code by resolving the foreign keys before inserting a new rows in the destination table? Is there any other better scaling solutions to suggests?

I tried to summarize I complex workflow, leaving out some details and generalizing a bit the context.

  • 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-23T13:50:46+00:00Added an answer on May 23, 2026 at 1:50 pm

    What percentage of the foreign keys don’t resolve ?

    You could do the following for each of those foreign key master tables

    INSERT INTO parent_table (id, name)
    SELECT id.nextval, r2.name
    FROM (SELECT DISTINCT r.name FROM raw)
    WHERE r2.name NOT IN (SELECT name FROM parent_table)
    

    Then you will know they all exist and can just do the insert.

    Or, if mostly they are there, you can look at BULK.. EXCEPTIONS INTO and let the SQL engine tell you which ones fail and deal with them individually.

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

Sidebar

Related Questions

I have a sheet full of some raw data, about 20,000 rows and 50
I have a client application that scrapes data into a raw table. This client
I have the following MySql table containing my raw event data (about 1.5 million
I have a table which has the raw data. In order to check for
I have a raw image file that is saved in binary data (no encoding).
I have a raw buffer with it i need to make 3 others, the
I have a raw image buffer in the RGB format. I need to draw
I have written a raw binary image file into a buffer which is an
I have an array of raw sound data samples, and I'm trying to make
I have a raw form-data that look like this: ------------V2ymHFg03ehbqgZCaKO6jy Content-Disposition: form-data; name=intro O

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.