Search code examples
phpmysqlgroup-concat

Mysql GROUP_CONCAT is extremely slow


I have a table in database with 450.000 rows.

Why is this query extremely slow? Can I fix it?

SELECT `ART_ARTICLE_NR`, `NAME`, `SUP_BRAND`, `PATH`, `CROSS_TYPE_NO`,
GROUP_CONCAT(`CATEG` ORDER BY `STR_LEVEL` ASC SEPARATOR '>>') AS CATEG2
FROM TOF_ARTICLES2
LIMIT 9

Solution

  • Looks like its doing full table scan, add an index if not done yet as

    alter table TOF_ARTICLES2 add index STR_LEVE_idx(STR_LEVE)