Как оптимизировать запросы в mysql?
Попробуйте без подзапросов:SELECT count(DISTINCT product.id)
    FROM `product`
    JOIN `product_to_city` ON `product`.`publish` = 1 
        AND `product`.`archive` != 1 AND `product`.`delete` != 1
        AND `product_to_city`.`product_id` = `product`.`id`
    JOIN `city` AS `c` ON (`c`.`id` = 104 OR `c`.`parent_id` = 104)
        AND `c`.`id` = `product_to_city`.`city_id`
    JOIN `city` ON `city`.`id` = `product`.`city_id`
    JOIN `company` ON `company`.`id` = `product`.`company_id`
кеширование, процедурки, индексы