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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:43:23+00:00 2026-06-10T17:43:23+00:00

What is faster? the Merge statement MERGE INTO table_name USING dual ON (row_id =

  • 0

What is faster?

the Merge statement

    MERGE INTO table_name 
     USING dual
     ON (row_id = 'some_id')
    WHEN MATCHED THEN
     UPDATE SET col_name = 'some_val'
    WHEN NOT MATCHED THEN
     INSERT (row_id, col_name)
     VALUES ('some_id', 'some_val')

or

querying a select statement then using an update or insert statement.

    SELECT * FROM table_name where row_id = 'some_id'

if rowCount == 0

    INSERT INTO table_name (row_id,col_name) VALUES ('some_id','some_val')

else

    UPDATE table_name SET col_name='some_val' WHERE row_id='some_id'
  • 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-10T17:43:25+00:00Added an answer on June 10, 2026 at 5:43 pm

    The rule of thumb is, if you can do it in one SQL, it’ll generally perform better than doing it in multiple SQL statements.

    I’d go with the MERGE if it does the job.

    Also – another suggestion: you can avoid repeating data in your statement, e.g.:

    MERGE INTO table
     USING (SELECT 'some_id' AS newid,
                   'some_val' AS newval
            FROM dual)
     ON (rowid = newid)
    WHEN MATCHED THEN
     UPDATE SET colname = newval
    WHEN NOT MATCHED THEN
     INSERT (rowid, colname)
     VALUES (newid, newval)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

what would be the fastest way to merge a list of numpy arrays into
Implement an algorithm to merge an arbitrary number of sorted lists into one sorted
I am trying to merge several data.frames into one data.frame . Since I have
What is faster having a String and then calling Substring for this String where
What I'm doing is merge 2 images into single image. Here is the code.
Is there any application to merge small images into a single one in a
Is it better / faster inside an event listener to use this or event.target
Possible Duplicate: Which is faster/best? SELECT * or SELECT column1, colum2, column3, etc I
Is it generally better/faster to do: if (condition) return a else if (condition2) return
which is better or faster, A or B? std::deque<Myclass> queue; ... // do something

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.