I have a list with filters and I have to count how many items are in each one filter, but the following query gets slower and much slower when multiple filters are set SELECT COUNT(*) FROM ( SELECT itf.`filter_id` FROM `item_to_filter` AS `itf` JOIN `item_to_inventory` AS `iti` ON (itf.`item_id` = iti.`item_id` AND iti.`quantity` > 0)Read more