# Suche extrem langsam

**URL:** https://forum.shopware.com/t/suche-extrem-langsam/61869
**Category:** Installation/Einstieg
**Created:** [19. September 2019 um 15:27 UTC](https://forum.shopware.com/t/suche-extrem-langsam/61869 "2019-09-19T15:27:31Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![cenzo81](https://avatars.discourse-cdn.com/v4/letter/c/8baadc/32.png) [@cenzo81](https://forum.shopware.com/u/cenzo81)
#### Post date: [19. September 2019 um 15:27 UTC](https://forum.shopware.com/t/suche-extrem-langsam/61869/1 "2019-09-19T15:27:31Z")

</div>

Hallo zusammen,  
ich habe die Shopware Version 5.6.1 mit ca 58.000 Artikel.

Wenn ich im Shop nach etwas suche dauert es extrem lange bis ich ein Ergebnis bekomme (ca 12 Sekunden) woran kann das liegen?  
Das einzige was dann hilft ist die Shopware Datenbank zu löschen und wieder neu zu importieren dann rennt die Suche wieder Pfeilschnell.

In der Datenbank sehe ich auch das Statement welches so lange braucht aber was kann ich hier tun ?  
\>\> SELECT SQL\_CALC\_FOUND\_ROWS product.id as \_\_product\_id, variant.id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as \_\_variant …

&nbsp;

---

<div class="post-metadata">

### Author: ![msslovi0](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@msslovi0](https://forum.shopware.com/u/msslovi0)
#### Post date: [19. September 2019 um 16:04 UTC](https://forum.shopware.com/t/suche-extrem-langsam/61869/2 "2019-09-19T16:04:41Z")

</div>

Wie lautet denn die komplette Query? Was ergibt ein EXPLAIN dieser Query?

Gruß

Matt

---

<div class="post-metadata">

### Author: ![shyim](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/shyim/32/7681_2.png) [@shyim](https://forum.shopware.com/u/shyim)
#### Post date: [19. September 2019 um 16:27 UTC](https://forum.shopware.com/t/suche-extrem-langsam/61869/3 "2019-09-19T16:27:42Z")

</div>

Meist liegt es an der Varianten Suche oder den Preisfiltern&nbsp;

---

<div class="post-metadata">

### Author: ![cenzo81](https://avatars.discourse-cdn.com/v4/letter/c/8baadc/32.png) [@cenzo81](https://forum.shopware.com/u/cenzo81)
#### Post date: [20. September 2019 um 07:58 UTC](https://forum.shopware.com/t/suche-extrem-langsam/61869/4 "2019-09-20T07:58:25Z")

</div>

Naja was mich so wundert, ich hab keine Plugins installiert der Shop ist also Quasi von der Stange ohne große anpassungen und der Fehler begleitet mich schon eine ganze Weile. Ich hab Aktuell die Datenbank neu aufgebaut jetzt läuft alles wieder performat. Sobald die Suche wieder anfängt zu lahmen werd ich das entsprechende SQL Statement posten. Danke mal für eure schnelle Antwort.

Ich hoffe wir kriegen das Problem gelöst.

---

<div class="post-metadata">

### Author: ![cenzo81](https://avatars.discourse-cdn.com/v4/letter/c/8baadc/32.png) [@cenzo81](https://forum.shopware.com/u/cenzo81)
#### Post date: [7. Oktober 2019 um 11:51 UTC](https://forum.shopware.com/t/suche-extrem-langsam/61869/5 "2019-10-07T11:51:03Z")

</div>

Heute trat der „Fehler“ wieder auf das Suggest bracuht eeewig bis ein Suchergebnis angezeigt wird.  
Hab mir mal das komplette SQL geloggt, vielleicht kann mir jemand sagen warum das Statement soo lange braucht.  
Erst wenn ich die Datenbank lösche und neu importiere läuft die Suche wieder performant.

SELECT SQL\_CALC\_FOUND\_ROWS product.id as \_\_product\_id, variant.id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as \_\_variant\_id, variant.ordernumber&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; as \_\_variant\_ordernumber, searchTable.\* FROM s\_articles product INNER JOIN s\_articles\_details variant ON variant.id = product.main\_detail\_id  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND variant.active = 1  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND product.active = 1 LEFT JOIN s\_articles\_avoid\_customergroups avoidCustomerGroup ON avoidCustomerGroup.articleID = product.id  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND avoidCustomerGroup.customerGroupId IN (1) INNER JOIN (SELECT a.id as product\_id, (sr.relevance  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + IF(a.topseller = 1, 50, 0)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + IF(a.datum \>= DATE\_SUB(NOW(),INTERVAL 7 DAY), 25, 0)) as ranking FROM (SELECT srd.articleID, SUM(srd.relevance) as relevance, COUNT(DISTINCT term) as termCount FROM (  
SELECT MAX(sf.relevance \* sm.relevance) as relevance, sm.keywordID, term, si.elementID as articleID FROM (SELECT 100 as relevance, ‚dichtung‘ as term, 662 as keywordID  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UNION ALL SELECT 50 as relevance, ‚dichtung‘ as term, 3176 as keywordID  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UNION ALL SELECT 50 as relevance, ‚dichtung‘ as term, 111186 as keywordID  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; …  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UNION ALL SELECT 50 as relevance, ‚dichtung‘ as term, 2390 as keywordID  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UNION ALL SELECT 50 as relevance, ‚dichtung‘ as term, 107078 as keywordID  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UNION ALL SELECT 50 as relevance, ‚dichtung‘ as term, 2386 as keywordID  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UNION ALL SELECT 50 as relevance, ‚dichtung‘ as term, 108174 as keywordID  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UNION ALL SELECT 50 as relevance, ‚dichtung‘ as term, 2387 as keywordID) sm INNER JOIN s\_search\_index si ON sm.keywordID = si.keywordID INNER JOIN s\_search\_fields sf ON si.fieldID = sf.id AND sf.relevance != 0 AND sf.tableID = 1 GROUP BY articleID, sm.term, sf.id  
&nbsp;&nbsp;&nbsp;&nbsp; UNION ALL  
SELECT MAX(sf.relevance \* sm.relevance) as relevance, sm.keywordID, term, st2.articleID as articleID FROM (SELECT 100 as relevance, ‚dichtung‘ as term, 662 as keywordID  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UNION ALL SELECT 50 as relevance, ‚dichtung‘ as term, 108174 as keywordID  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UNION ALL SELECT 50 as relevance, ‚dichtung‘ as term, 2387 as keywordID) sm INNER JOIN s\_search\_index si ON sm.keywordID = si.keywordID INNER JOIN s\_search\_fields sf ON si.fieldID = sf.id AND sf.relevance != 0 AND sf.tableID = 5 GROUP BY articleID, sm.term, sf.id) srd GROUP BY srd.articleID ORDER BY relevance DESC LIMIT 5000) sr INNER JOIN s\_articles a ON a.id = sr.articleID)) searchTable ON searchTable.product\_id = product.id INNER JOIN s\_articles\_categories\_ro productCategory ON productCategory.articleID = product.id  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AND productCategory.categoryID IN (3) INNER JOIN s\_articles\_attributes productAttribute ON productAttribute.articledetailsID = variant.id WHERE avoidCustomerGroup.articleID IS NULL GROUP BY product.id ORDER BY searchTable.ranking DESC, variant.id ASC LIMIT 6

---

<div class="post-metadata">

### Author: ![cenzo81](https://avatars.discourse-cdn.com/v4/letter/c/8baadc/32.png) [@cenzo81](https://forum.shopware.com/u/cenzo81)
#### Post date: [10. Oktober 2019 um 17:27 UTC](https://forum.shopware.com/t/suche-extrem-langsam/61869/6 "2019-10-10T17:27:08Z")

</div>

Hat den keiner auch nur irgend eine Idee. Kann doch nicht sein dass ich allein das Problem hab ?

&nbsp;

---

<div class="post-metadata">

### Author: ![kulli](https://avatars.discourse-cdn.com/v4/letter/k/a3d4f5/32.png) [@kulli](https://forum.shopware.com/u/kulli)
#### Post date: [11. Oktober 2019 um 09:59 UTC](https://forum.shopware.com/t/suche-extrem-langsam/61869/7 "2019-10-11T09:59:34Z")

</div>

Mit 58.000 Artikeln denke ich die Datenbank ist etwas überlastet bei der Suche.

Mein erster Tipp wären da auch auf die Filter.

Oder mal an den Sucheinstellungen schrauben (Relevanz, Distanz und Faktor)

---

<div class="post-metadata">

### Author: ![mm\_mathias](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@mm\_mathias](https://forum.shopware.com/u/mm_mathias)
#### Post date: [15. Oktober 2019 um 15:51 UTC](https://forum.shopware.com/t/suche-extrem-langsam/61869/8 "2019-10-15T15:51:56Z")

</div>

Hallo cenzo81,

wir haben auch das Problem, dass die Suche alles andere als performant ist.

Es liegt (zumindest bei uns) an der Anzahl Einträge in der Tabelle s\_statistics\_search. Wenn wir diese leeren, wird die Suche wieder schnell.

So ab ca. 100.000 Einträgen dauerts schon 2-4 Sekunden bis ein Ergebnis angezeigt wird. Bei noch mehr Einträgen steigt die Antwortzeit rapide an.

Genauer habe ich mir das noch nicht angesehen aber ich vermute es liegt daran, dass die Suche nach geeigneten Begriffen für „oder meinten Sie…“ sucht.

Viele Grüße

Mathias

---

<div class="post-metadata">

### Author: ![cenzo81](https://avatars.discourse-cdn.com/v4/letter/c/8baadc/32.png) [@cenzo81](https://forum.shopware.com/u/cenzo81)
#### Post date: [8. November 2019 um 12:53 UTC](https://forum.shopware.com/t/suche-extrem-langsam/61869/9 "2019-11-08T12:53:44Z")

</div>

Hi Mathias,

ich danke dir für deine Antwort leider hat die Tabelle bei mir gerade mal 1600 Einträge. Hab die Tabelle auch mal bereinigt, aber die Suche ist mal wieder sowas von langsam.  
Das Suggest benötigt mehr als 10 Sekunden bis hier mal was angezeigt wird.  
Hat jemand eine Idee wie ich den Fehler analysieren kann ? In der Mysql Error Log steht nichts. Wenn ich in der Datanbank die processlist ausgebe dann ist das Statement sooo groß dass ich es nicht wirklich analysieren kann.

Der Fehler ist dann erst nach erneutem einspielen der Datenbank weg und kommt meist ein Tags später wieder.

Hat hier noch jemand ne Ahnung wie ich hier vorgehen kann ? So ist der Shop ja absolut unbrauchbar und jeder Kunde verabschiedet sich doch direkt wieder.

&nbsp;
