I have this SQL here:
SELECT id, nome, url FROM categorias WHERE status = 1 AND id_ls IN
(SELECT id_categoria FROM cliente_categorias) GROUP BY url
What it does is fetch only categories that have clients assigned to them.
My categories table has 1,477 records and customer_categories 23,616:
It works. The problem is that the load is soooo slow. The query takes about 17 seconds. Is there any way for me to improve?