Chris: LEFT JOIN viel zu langsam

Beitrag lesen

Hallo,

irgendwie ist mein SELECT ziemlich langsam, etliche Sekunden und ich weiß nicht so recht woran das liegen könnte.

  
SELECT a.lagerstatus, a.herstellernr, a.hide_shop, b.actebis_herstlnr, b.actebis_lagerbestand, c.also_herstnr, c.also_bestand, d.techdata_herstlnr, d.techdata_lagerbestand, e.namede, e.kategorie, e.hide_shop, f.ingram_bestand, f.ingram_herstnr, g.bcom_bestand, g.bcom_herstnr, GREATEST(b.actebis_lagerbestand, c.also_bestand, d.techdata_lagerbestand, f.ingram_bestand, g.bcom_bestand) AS MaxBestand  
FROM tspi_article a  
LEFT JOIN tspi_actebis b ON (a.herstellernr = b.actebis_herstlnr OR a.herstellernr2 = b.actebis_herstlnr OR a.herstellernr3 = b.actebis_herstlnr)  
LEFT JOIN tspi_also c ON (a.herstellernr = c.also_herstnr OR a.herstellernr2 = c.also_herstnr OR a.herstellernr3 = c.also_herstnr)  
LEFT JOIN tspi_techdata d ON (a.herstellernr = d.techdata_herstlnr OR a.herstellernr2 = d.techdata_herstlnr OR a.herstellernr3 = d.techdata_herstlnr)  
LEFT JOIN tspi_ingram f ON (a.herstellernr = f.ingram_herstnr OR a.herstellernr2 = f.ingram_herstnr OR a.herstellernr3 = f.ingram_herstnr)  
LEFT JOIN tspi_article_group e ON a.gruppe = e.namede  
LEFT JOIN tspi_bcom g ON (a.herstellernr = g.bcom_herstnr OR a.herstellernr2 = g.bcom_herstnr OR a.herstellernr3 = g.bcom_herstnr)  
WHERE a.lagerstatus!='Sofort lieferbar'  
AND a.hide_shop=0  
AND e.hide_shop=0  
AND e.kategorie!='Gutscheine'  
AND e.kategorie!='Zubehör'  
ORDER BY 'MaxBestand' DESC  

Ein explain gibt folgendes aus:

+-------+------+-------------------+-----------+---------+-----------+-------+----------------------------------------------+
| table | type | possible_keys     | key       | key_len | ref       | rows  | Extra                                        |
+-------+------+-------------------+-----------+---------+-----------+-------+----------------------------------------------+
| a     | ref  | gruppe,hide_shop  | hide_shop | 4       | const     | 1961  | Using where; Using temporary; Using filesort |
| e     | ref  | name,hide_shop    | name      | 50      | a.gruppe  | 1     | Using where                                  |
| b     | ALL  | actebis_herstlnr  | NULL      | NULL    | NULL      | 555   |                                              |
| c     | ALL  | also_herstnr      | NULL      | NULL    | NULL      | 582   |                                              |
| d     | ALL  | techdata_herstlnr | NULL      | NULL    | NULL      | 556   |                                              |
| f     | ALL  | ingram_herstnr    | NULL      | NULL    | NULL      | 537   |                                              |
| g     | ALL  | bcom_herstnr      | NULL      | NULL    | NULL      | 97    |                                              |
+-------+------+-------------------+-----------+---------+-----------+-------+----------------------------------------------+

Die 5 Tabellen die den type "ALL" haben, sind vom Aufbau her alle gleich:

  
CREATE TABLE tspi_bcom (  
  bcom_id int(10) NOT NULL auto_increment,  
  bcom_artnr varchar(255) NOT NULL default '',  
  bcom_herstnr varchar(255) NOT NULL default '',  
  bcom_ep varchar(255) NOT NULL default '',  
  bcom_bestand varchar(255) NOT NULL default '',  
  bcom_beschreibung text NOT NULL,  
  bcom_herstlname varchar(255) NOT NULL default '',  
  PRIMARY KEY  (bcom_id),  
  UNIQUE KEY bcom_id (bcom_id),  
  KEY bcom_herstnr (bcom_herstnr),  
  KEY bcom_bestand (bcom_bestand),  
  KEY bcom_ep (bcom_ep)  
) TYPE=MyISAM;  

DB-Version ist: 4.00.25

Wo könnte ich nun was verbessern?

Danke und Grüße

Chris