MySQL Forums
Forum List  »  German

Performance Problem bei großen Abfragen
Posted by: Lars Düwel
Date: October 15, 2009 05:30AM

Hallo, ich habe 2 Fragen zu dem Query (siehe unten) da sehr große Abfragen bis zu 60sek brauchen.
1. Warum werden keine Indexe benutzt, bzw. kann ich das ändern?
2. Warum entspricht "Row" im Explain der gesamten Größe meiner Tabelle obwohl ich nur ein Teil der Daten abfrage?

//SELECT
// IFNULL(m.marktnummer, 'OVERALL_RESULT') as MarktID,
// m.Ort as Marktname,
// IFNULL(h.ArtikelID, 'MARKT_RESULT') as ProduktID,
// KochID,
// p.PKochID as PKochID,
// m.vmi,
// p.artikelname as Artikelname,
// IFNULL(Datum, 'PRODUKT_RESULT') as Date,
// SUM(Verkauf) AS Verkauf,
// Lager
//FROM
// heapStatistik as h,
// markt as m,
// produkte as p
//WHERE
// h.MarktID IN ('$markt') AND
// h.ArtikelID IN ('$produkt') AND
// Datum IN ('$date') AND
// h.MarktID = m.marktnummer AND
// h.ArtikelID = p.Medianummer
//GROUP BY
// MarktID,
// h.ArtikelID,
// h.Datum
//WITH ROLLUP HAVING
// (
// ProduktID != 'MARKT_RESULT' AND
// Date = 'PRODUKT_RESULT'
// )


+----+-------------+-------+------+---------------+-------------+---------+---------------+---------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+-------------+---------+---------------+---------+----------------------------------------------+
| 1 | SIMPLE | h | ALL | MarktID | NULL | NULL | NULL | 3934577 | Using where; Using temporary; Using filesort |
| 1 | SIMPLE | m | ref | marktnummer | marktnummer | 12 | vmi.h.MarktID | 1 | Using where |
| 1 | SIMPLE | p | ALL | NULL | NULL | NULL | NULL | 785 | Using where |
+----+-------------+-------+------+---------------+-------------+---------+---------------+---------+----------------------------------------------+
3 rows in set (0.00 sec)

Options: ReplyQuote


Subject
Views
Written By
Posted
Performance Problem bei großen Abfragen
3048
October 15, 2009 05:30AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.