SELECT 
  DISTINCT pc.category_id, 
  count(DISTINCT pc.product_id) as total_products 
FROM 
  tmall_products AS products 
  LEFT JOIN tmall_products_categories AS pc ON products.product_id = pc.product_id 
  LEFT JOIN tmall_products_categories AS ab__products_categories ON ab__products_categories.product_id = products.product_id 
WHERE 
  1 
  AND ab__products_categories.category_id IN (243) 
GROUP BY 
  pc.category_id

Query time 0.00766

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.133774664,
    "filesort": {
      "sort_key": "pc.category_id",
      "temporary_table": {
        "nested_loop": [
          {
            "table": {
              "table_name": "ab__products_categories",
              "access_type": "ref",
              "possible_keys": ["PRIMARY", "pt"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["category_id"],
              "ref": ["const"],
              "loops": 1,
              "rows": 6,
              "cost": 0.001620162,
              "filtered": 100,
              "using_index": true
            }
          },
          {
            "table": {
              "table_name": "products",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["product_id"],
              "ref": ["tmall.ab__products_categories.product_id"],
              "loops": 6,
              "rows": 1,
              "cost": 0.004005362,
              "filtered": 100,
              "using_index": true
            }
          },
          {
            "table": {
              "table_name": "pc",
              "access_type": "ref",
              "possible_keys": ["pt"],
              "key": "pt",
              "key_length": "3",
              "used_key_parts": ["product_id"],
              "ref": ["tmall.ab__products_categories.product_id"],
              "loops": 6,
              "rows": 11,
              "cost": 0.085373628,
              "filtered": 100
            }
          }
        ]
      }
    }
  }
}

Result

category_id total_products
243 5