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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:25:30+00:00 2026-05-19T00:25:30+00:00

I have ~2 million rows or so of data, each row with an artificial

  • 0

I have ~2 million rows or so of data, each row with an artificial PK, and two Id fields (so: PK, ID1, ID2). I have a unique constraint (and index) on ID1+ID2.

I get two sorts of updates, both with a distinct ID1 per update.

  1. 100-1000 rows of all-new data (ID1 is new)
  2. 100-1000 rows of largely, but not necessarily completely overlapping data (ID1 already exists, maybe new ID1+ID2 pairs)

What’s the most efficient way to maintain this ‘set’? Here are the options as I see them:

  1. Delete all the rows with ID1, insert all the new rows (yikes)
  2. Query all the existing rows from the set of new data ID1+ID2, only insert the new rows
  3. Insert all the new rows, ignore inserts that trigger unique constraint violations

Any thoughts?

  • 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-19T00:25:31+00:00Added an answer on May 19, 2026 at 12:25 am

    Not all of your listed solutions are functionally equivalent, so without more knowledge about what you want or need to accomplish, it’s hard to say which is most appropriate.

    1. You may lose data that you want or need to keep.
    2. Based on the table schema that you mentioned, this should be reasonable.
    3. This will only work if you perform each INSERT separately.

    I’d suggest [2] based on the available info.

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

Sidebar

Related Questions

I have a million rows in a database table. For each row I have
I have a table with about 35 million rows. each has about 35 integer
I have two tables with 10-20 million rows that have GUID primary keys and
I have one million rows of data in .txt format. the format is very
I have a large file, with 1.8 million rows of data, that I need
Background: I have a fixed-width flat file with about 94 million rows of data.
I have 1 million rows in MySql table temp and wish to multiply column
I have 3 million rows customers.csv file. When I import it in SQL 2008,
We have a large table (450 million rows containing 34 columns of numeric or
I have a items table with 1 million rows and a users table 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.