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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:48:30+00:00 2026-05-15T03:48:30+00:00

Which one of below query has better performance? What’s the upside/downside for both query?

  • 0

Which one of below query has better performance? What’s the upside/downside for both query? I want to discuss the scenario for inserting 1000 rows and 100k rows Thanks.

1st

INSERT INTO table_name (col1,col2) VALUES (value1, value2);
INSERT INTO table_name (col1,col2) VALUES (value3, value4);

2nd

INSERT INTO table_name
SELECT (col1,col2) 
FROM (
    SELECT value1 as col1, value2 as col2 UNION ALL
    SELECT value3 as col1, value4 as col2
) A
  • 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-15T03:48:30+00:00Added an answer on May 15, 2026 at 3:48 am

    The second query will perform better because the DB engine has to analyze and execute only one statement.But the difference will be insignificant and will matter only for large inserts (more than 100) But the best approach would be

    INSERT INTO table_name (col1,col2) VALUES (value1, value2),(value3, value4); 
    

    but your syntax for query 2 should be
    INSERT INTO table_name
    SELECT col1,col2
    FROM (
    SELECT value1 as col1, value2 as col2 UNION ALL
    SELECT value3 as col1, value4 as col4
    ) A

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

Sidebar

Related Questions

Which one below is correct? First code has no quotes in the $_GET array
I have an XML file which has many section like the one below: <Operations>
Which one is better when performance is taken into consideration an if else if
The first one is definitely something that works, but which one below is the
Of the below three functions: getc getchar & scanf which is the best one
Which one performs better to run a game main loop?
which one of the two is more spread? I want to read out the
I have a query which takes a long time and I want to optimize
I'm stuck one query here. I need see that which products customer X hasn't
I have a log file (.txt) which has information as below: Filename1 - A3332NCDER

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.