SELECT 
  DISTINCT pc.category_id, 
  count(DISTINCT pc.product_id) as total_products 
FROM 
  cscart_products AS products 
  LEFT JOIN cscart_products_categories AS pc ON products.product_id = pc.product_id 
  LEFT JOIN cscart_product_features_values AS product_features_values_657 ON product_features_values_657.product_id = products.product_id 
  AND product_features_values_657.feature_id = 657 
WHERE 
  1 
  AND product_features_values_657.variant_id = 9152 
GROUP BY 
  pc.category_id

Query time 0.00363

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "417.33"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "166.48"
      },
      "nested_loop": [
        {
          "table": {
            "table_name": "product_features_values_657",
            "access_type": "ref",
            "possible_keys": [
              "PRIMARY",
              "fl",
              "variant_id",
              "product_id",
              "fpl",
              "idx_product_feature_variant_id"
            ],
            "key": "variant_id",
            "used_key_parts": [
              "variant_id"
            ],
            "key_length": "3",
            "ref": [
              "const"
            ],
            "rows_examined_per_scan": 467,
            "rows_produced_per_join": 83,
            "filtered": "17.82",
            "cost_info": {
              "read_cost": "116.75",
              "eval_cost": "8.32",
              "prefix_cost": "163.45",
              "data_read_per_join": "64K"
            },
            "used_columns": [
              "feature_id",
              "product_id",
              "variant_id"
            ],
            "attached_condition": "((`softwarepirmam_hewadelivard_cscart_4`.`product_features_values_657`.`feature_id` = 657) and (`softwarepirmam_hewadelivard_cscart_4`.`product_features_values_657`.`product_id` is not null))"
          }
        },
        {
          "table": {
            "table_name": "products",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "ref": [
              "softwarepirmam_hewadelivard_cscart_4.product_features_values_657.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 83,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "20.81",
              "eval_cost": "8.32",
              "prefix_cost": "192.58",
              "data_read_per_join": "368K"
            },
            "used_columns": [
              "product_id"
            ]
          }
        },
        {
          "table": {
            "table_name": "pc",
            "access_type": "ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "ref": [
              "softwarepirmam_hewadelivard_cscart_4.product_features_values_657.product_id"
            ],
            "rows_examined_per_scan": 2,
            "rows_produced_per_join": 166,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "41.62",
              "eval_cost": "16.65",
              "prefix_cost": "250.85",
              "data_read_per_join": "2K"
            },
            "used_columns": [
              "product_id",
              "category_id"
            ]
          }
        }
      ]
    }
  }
}

Result

category_id total_products
174 4
372 17
384 8
423 4
453 4
460 2
466 20
467 3
474 5
475 4
554 4
556 7
566 12
572 3
573 14
574 24
575 10
578 9
579 5
587 13
597 14
598 2
655 1