Hallo,
habe mal eine echte Performancefrage zum Tabellenvergleich
Ausgangsituation:
Tabelle1 mit spalten a,b,x
Tabelle2 mit splaten g,h,i,j,x
In die Zieltabelle3 (g,h,i,j,x) sollen alle aus Tabelle2, die nicht in Tabelle1 sind.
Abgleich über x
Habe nun folgendes gemacht:
INSERT INTO `db`.`tab3`
SELECT *
FROM `db`.`tab2`
WHERE `x` not IN (SELECT x FROM `db`.`tab1`);
Es kam keine Fehlermeldung, allerding weiß ich nicht, was nun passiert. Der Prozess läuft, Time ist 339826.
Habe ich da schon einen Syntaxfehler (ein x ist ohne `)?
Die Herausforderung, beide Tabellen haben über 13 Mio Datensätze.
Nun muss ich das Beschleunigen:
System ist 64bit Prozessor, 4 GB Ram, Debian 64bit
MySQL ist die aktuelle LAMPP version, ist nur 32 bit. Evtl hier auf MySQL 5.5 64bit updaten (wie/howto)?
Ich benötige das LAMPP Paket eigentlich nicht, da ich via SSH auf der mysql-Konsole die Befehle eingebe.
Evtl. später, um die Befehle über eine Weboberfläche zu händeln.
Anstelle des where ein Join Befehl (danke für die Übersicht hier im Forum, habe es nun begriffen, super)?
Nun habe ich irgendwo schon gelesen, daß ich Tabelen sperren kann, Index muss nicht erstellt werden usw, wer hat da Erfahrung?
Hier die Tabellen:
| tab1 | CREATE TABLE `tab1` (
`a` text COLLATE utf8_unicode_ci NOT NULL,
`b` text COLLATE utf8_unicode_ci NOT NULL,
`x` text COLLATE utf8_unicode_ci NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci |
| tab2 | CREATE TABLE `tab2` (
`g` text COLLATE utf8_unicode_ci NOT NULL,
`h` text COLLATE utf8_unicode_ci NOT NULL,
`i` text COLLATE utf8_unicode_ci NOT NULL,
`j` text COLLATE utf8_unicode_ci NOT NULL,
`k` text COLLATE utf8_unicode_ci NOT NULL,
`l` text COLLATE utf8_unicode_ci NOT NULL,
`m` text COLLATE utf8_unicode_ci NOT NULL,
`n` text COLLATE utf8_unicode_ci NOT NULL,
`o` text COLLATE utf8_unicode_ci NOT NULL,
`p` text COLLATE utf8_unicode_ci NOT NULL,
`q` text COLLATE utf8_unicode_ci NOT NULL,
`r` text COLLATE utf8_unicode_ci NOT NULL,
`s` text COLLATE utf8_unicode_ci NOT NULL,
`x` text COLLATE utf8_unicode_ci NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci |