473,396 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help: rejecting duplicate rows

I'm sorry, I had a couple of typos in my original post.
Here is the corrected version:

How can I make MySQL reject duplicate rows when inserting?

The table is quite large: 100+ columns and millions of rows.

MySQL doesn't allow me to create a UNIQUE INDEX for all the columns
(16 columns is the max.)

The brute force method (selecting the new candidate row and inserting
only when not found) is way too slow.

Any help is appreciated.

Sep 6 '05 #1
2 3031
g_*****@yahoo.com wrote:
I'm sorry, I had a couple of typos in my original post.
Here is the corrected version:

How can I make MySQL reject duplicate rows when inserting?

The table is quite large: 100+ columns and millions of rows.

MySQL doesn't allow me to create a UNIQUE INDEX for all the columns
(16 columns is the max.)

The brute force method (selecting the new candidate row and inserting
only when not found) is way too slow.

Any help is appreciated.


Try INSERT IGNORE INTO ....
this will omit conflicting new records where there is a duplication on
an unique key

--
Sep 6 '05 #2
>> I'm sorry, I had a couple of typos in my original post.
Here is the corrected version:

How can I make MySQL reject duplicate rows when inserting?

The table is quite large: 100+ columns and millions of rows.

MySQL doesn't allow me to create a UNIQUE INDEX for all the columns
(16 columns is the max.)

The brute force method (selecting the new candidate row and inserting
only when not found) is way too slow.

Any help is appreciated.


Try INSERT IGNORE INTO ....
this will omit conflicting new records where there is a duplication on
an unique key


But he can't CREATE a unique key, since he needs a unique index over
more than 16 columns, and MySQL won't let him do that.

Just how many columns would the unique index need to cover? Is
there a possibility of combining some of them?

Example: if you've got columns a01 through a99, and you need the unique
index over all of them, add another column which is created from:

concat(a01, '|', a02, '|', ... , '|', a99)

and create a unique index on THAT. Of course, this is a pain to
do on all the inserts. This does presume that the values of the columns
a01 .. a99 can't have '|' as part of the value. As I recall, you can't
have an index cover more than 255 characters, and that might present a
problem in this case also.

Gordon L. Burditt
Sep 6 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: g_chime | last post by:
How can I make MySQL reject duplicate rows when inserting? The table is quite large: 100+ rows and millions of rows. MySQL doesn't allow me to create a UNIQUE INDEX for all the rows (16 rows...
1
by: Dusty Reagan | last post by:
I'm trying to create a query that finds rows w/ duplicate "ContactKeys" then finds duplicate "AddressLine1s" out of the list of duplicate "ContactKeys." (I tried subqueries but it was really slow)...
7
by: Steve B. | last post by:
Does anyone know why the DA Update() would throw an exception? I moved the database but I updated the Conn and the DA, currently (trying)removing/replacing DS. Is there a another direction I...
1
by: TaeHo Yoo | last post by:
I have a table that has more than 1 milion rows so practically it is impossible to remove all duplicate rows by hand. Could you help me to remove those duplicate rows at all? This table doesn't...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
10
by: mscurto | last post by:
What is the syntax for an sql command to get the following. I want to pull in a handful of fields from a table but one of the fields needs to be unique. For example, if I have a customer table...
7
by: cobolman | last post by:
I have a table with the following columns, NAME, TYPE, TAG And there may be 'duplicates' on name and type. How can I delete them?? I want to delete all with duplicate NAME and TYPE
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
118
by: Chuck Cheeze | last post by:
This might be in the wrong group, but... Here is an example of my data: entry_id cat_id 1 20 2 25 3 30 4 25 5 35
2
by: yeshello54 | last post by:
so here is my problem...in a contact manager i am trying to complete i have ran into an error..we have lots of code because we have some from class which we can use...anyways i keep getting an error...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.