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 
WHERE 
  1 
  AND products.product_id IN (
    23414, 23415, 23416, 23417, 23418, 23419, 
    23420, 23421, 23422, 23423, 23424, 
    23425, 23426, 23427, 23428, 23429, 
    23430, 23431, 23432, 23433, 23434, 
    23435, 23436, 23437, 23438, 23439, 
    23440, 23441, 23442, 23443, 23444, 
    23445, 23446, 23447, 23448, 23449, 
    23450, 23451, 23452, 23453, 23454, 
    23455, 23456, 23457, 23458, 23459, 
    23460, 23461, 23462, 23463, 23464, 
    23465, 23466, 23467, 23468, 23469, 
    23470, 23471, 23472, 23473, 23474, 
    23475, 23476, 23477, 23478, 23479, 
    23480, 23481, 23482, 23483, 23484, 
    23485, 23486, 23487, 23488, 23489, 
    23490, 23491, 23492, 23493, 23494, 
    23495, 23496, 23497, 23498, 23499, 
    23564, 23569, 23570, 23571, 23572, 
    23890, 23928, 23929, 23930, 23931
  ) 
GROUP BY 
  pc.category_id

Query time 0.00098

JSON explain

{
  "query_block": {
    "select_id": 1,
    "filesort": {
      "sort_key": "pc.category_id",
      "temporary_table": {
        "nested_loop": [
          {
            "table": {
              "table_name": "products",
              "access_type": "range",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["product_id"],
              "rows": 96,
              "filtered": 100,
              "attached_condition": "products.product_id in (23414,23415,23416,23417,23418,23419,23420,23421,23422,23423,23424,23425,23426,23427,23428,23429,23430,23431,23432,23433,23434,23435,23436,23437,23438,23439,23440,23441,23442,23443,23444,23445,23446,23447,23448,23449,23450,23451,23452,23453,23454,23455,23456,23457,23458,23459,23460,23461,23462,23463,23464,23465,23466,23467,23468,23469,23470,23471,23472,23473,23474,23475,23476,23477,23478,23479,23480,23481,23482,23483,23484,23485,23486,23487,23488,23489,23490,23491,23492,23493,23494,23495,23496,23497,23498,23499,23564,23569,23570,23571,23572,23890,23928,23929,23930,23931)",
              "using_index": true
            }
          },
          {
            "table": {
              "table_name": "pc",
              "access_type": "ref",
              "possible_keys": ["pt"],
              "key": "pt",
              "key_length": "3",
              "used_key_parts": ["product_id"],
              "ref": ["lillyshop_lillyshop.products.product_id"],
              "rows": 1,
              "filtered": 100
            }
          }
        ]
      }
    }
  }
}

Result

category_id total_products
1173 14
1174 1
1176 7
1177 40
1178 9
1179 25