Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Usuwanie duplikatów z 1,6mln rekordów
1q2w3e4r
post
Post #1





Grupa: Zarejestrowani
Postów: 238
Pomógł: 0
Dołączył: 6.05.2011

Ostrzeżenie: (10%)
X----


Witam,
Muszę usunąć duplikaty z 1,6mln rekordów.. Zastanawiam się jak to zrobić najszybciej.
Duplikaty mają się usuwać wierszami, czyli duplikaty jeśli jeden wiersz nie może się równać innemu.

Macie jakieś propozycje jak to zrobić?

Proszę o szybka odpowiedź.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
cojack
post
Post #2





Grupa: Zarejestrowani
Postów: 898
Pomógł: 80
Dołączył: 31.05.2008

Ostrzeżenie: (20%)
X----


Z http://dev.mysql.com/doc/refman/5.0/en/delete.html lekko przerobione:

Cytat
If you are deleting many rows from a large table, you may exceed the lock table size for an InnoDB table. To avoid this problem, or simply to minimize the time that the table remains locked, the following strategy (which does not use DELETE at all) might be helpful:

Select the rows not to be deleted into an empty table that has the same structure as the original table:

Kod
INSERT INTO t_copy SELECT DISTINCT * FROM t;

Use RENAME TABLE to atomically move the original table out of the way and rename the copy to the original name:

Kod
RENAME TABLE t TO t_old, t_copy TO t;


Drop the original table:

Kod
DROP TABLE t_old;
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 17.10.2025 - 23:03