my below select query that joins three tables (products, descriptions, images) takes 9 seconds to return just 10 rows!
SELECT `products`.id, `products`.serialNumber, `products`.title, `descriptions`.description1, `descriptions`.description2, `descriptions`.description3, `descriptions`.description4,`products`.price,`products`.colors, `products`.category, `products`.available, `products`.status, GROUP_CONCAT(DISTINCT `images`.file_name ORDER BY `images`.id) AS images
FROM `products`
INNER JOIN `descriptions`
ON `products`.id = `descriptions`.product_id
LEFT JOIN `images`
ON `products`.id = `images`.product_id
WHERE `products`.status = 1
GROUP BY `products`.id
ORDER BY `products`.id DESC
LIMIT 10;
so after some research, I have arrived to the below answer which contains joining two tables and takes just one second to return the 10 rows, how I can add to it the third table (descriptions)? thank you
SELECT *,
( SELECT group_concat(`images`.file_name)
FROM `images`
) AS images
FROM `products`
JOIN `images` ON `products`.id = `images`.product_id
WHERE `products`.status = 1
GROUP BY `products`.id
ORDER BY `products`.id DESC
LIMIT 10
question from:
https://stackoverflow.com/questions/65651477/mysql-joining-three-tables-takes-much-time-to-execute 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…