我想知道是否有任何方法可以使这个查询更快,查询时间:31,422s
SELECT
p.id_orden,
p.nombre,
pro.modelo,
GROUP_CONCAT(pa.nombre SEPARATOR ', ') AS acompanates,
GROUP_CONCAT(pa.precio SEPARATOR ', ') AS price,
ROUND(SUM(pa.precio) / 1.12 , 2) AS subtotal,
ROUND(ROUND(SUM(pa.precio) / 1.12 , 2) * 0.12 , 2) AS iva,
CONCAT(ROUND(SUM(pa.precio) / 1.12 , 2) + ROUND(ROUND(SUM(pa.precio) / 1.12 , 2) * 0.12 , 2)) as total
FROM orden p
LEFT JOIN producto_orden AS pro ON p.id_orden = pro.id_orden
LEFT JOIN acompanante_orden AS pa ON p.id_orden = pa.id_orden
GROUP BY p.id_orden
由于。。。导致的结果Explain
1 SIMPLE p ALL 8155 Using temporary; Using filesort
1 SIMPLE pro ALL 8327
1 SIMPLE pa ALL 2901