MySQL Forums
Forum List  »  German

Re: Simpler Join: Komplette Tabelle wird gescannt
Posted by: Thomas Wiedmann
Date: December 22, 2012 10:53AM

So richtig gut lesen kann man es nicht, aber das Wesentliche kann ich erkennen. (Wenn Du den EXPLAIN ein der MySQL Kommandozeile ausführst, kommt eine saubere EXPLAIN Ausgabe zustande).

Okay, die große Datenmenge läuft bei der Tabelle WETTEN auf:

id 	select_type 		table 			type 	possible_keys 					key 			key_len 	ref 	rows 	Extra
1 	PRIMARY 		wetten 			range 	PRIMARY,zeit_wettende,kategorie,kategorie_2 	zeit_wettende 		4 		NULL	10900 	Using where; Using filesort

Es wird zwar ein kex verwendet, aber ein Sort auf der Platte (oder RAM) wegen dem ORDER BY ist trotzdem noch nötig (using filesort)


Folgendes läßt sich optisch noch optimieren (keine Performancevorteil)

anstatt
....
       SELECT count(*)
         FROM wetten_wetten
        WHERE spezial_oberwette = wettID
          AND wetten_wetten.spezialart != 925
          AND wetten_wetten.spezialart != 920
          AND wetten_wetten.spezialart != 917
          AND wetten_wetten.spezialart != 1189
       ) AS anzahlSpezis


dies
...
       SELECT count(*)
         FROM  wetten_wetten
        WHERE spezial_oberwette = wettID
          AND wetten_wetten.spezialart NOT IN (925, 920, 917, 1189)
       ) AS anzahlSpezis

...

Kannst ja nochmal die Ausgabe von :

* SHOW VARIABLES LIKE '%buffer%'; -- wichtige MySQL Server Einstellungen

zeigen.

Letztlich schon verwunderlich, dass mit und ohne GROUP BY das korrekte Ergebnis rauskommt. Bitte genau prüfen...!

Grüße
Thomas

Options: ReplyQuote




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.