MySQL Forums
Forum List  »  German

Endlos langes SQL-Query
Posted by: Arne Göbel
Date: March 02, 2016 04:58AM

Hallo,

habe ein Problem mit einem komplexen SQL-Query. Ich führe einen LEFT JOIN mit einem Subselect aus, welcher ca. 60000 Datensätze zurückliefert. Hier das Statement:

SELECT SQL_CALC_FOUND_ROWS
table0.`id`,
...
trackingNotizen.`notizen`
FROM
`tracking` table0
INNER JOIN
`benutzer` table1 ON table0.`mitarbeiter` = table1.`id`
INNER JOIN
`jobs` table2 ON table0.`job` = table2.`id`
LEFT JOIN
(SELECT
tr.tracking,
GROUP_CONCAT(CONCAT('', tr.type, ': ', tr.notiz)
SEPARATOR '#') AS notizen
FROM
tracking_notizen tr
INNER JOIN tracking t ON tr.tracking = t.id
GROUP BY tr.tracking, t.mitarbeiter) trackingNotizen ON table0.`id` = trackingNotizen.`tracking`
ORDER BY `id` DESC
LIMIT 0 , 25;

Nun läuft dieses Query endlos und gibt kein Ergebnis zurück. Wenn ich in dem Subquery z.B. ein WHERE t.von > '2016-03-01' hinzufüge, dann funktioniert es, da die Datenbasis nicht mehr 60000, sondern ca. 200 sind. Beim Ausführen des einzelnen Subqueries gibt es keinerlei Geschwindigkeitsprobleme (Alle 60000 Datensätze in 3 Sekunden). Durch einen Inner Join anstatt eines Left Joins läuft es auch sehr schnell durch, ca. 3 Sekunden. In Kombination mit einem Left Join kommt es aber zur Endlos-Ausführung.

Was kann ich ändern, damit dieses Query schnell läuft.

Vielen Dank schonmal.

Options: ReplyQuote


Subject
Views
Written By
Posted
Endlos langes SQL-Query
1732
March 02, 2016 04:58AM


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.