SELECT 
  q_products_categories.product_id, 
  GROUP_CONCAT(
    IF(
      q_products_categories.link_type = "M", 
      CONCAT(
        q_products_categories.category_id, 
        "M"
      ), 
      q_products_categories.category_id
    )
  ) AS category_ids 
FROM 
  q_products_categories 
  INNER JOIN q_categories ON q_categories.category_id = q_products_categories.category_id 
  AND (
    q_categories.usergroup_ids = '' 
    OR FIND_IN_SET(0, q_categories.usergroup_ids) 
    OR FIND_IN_SET(1, q_categories.usergroup_ids)
  ) 
  AND q_categories.status IN ('A', 'H') 
WHERE 
  q_products_categories.product_id IN (
    9549, 9550, 9551, 9552, 9553, 9554, 9555, 
    9556, 9557, 9558, 9559, 9560, 9561, 
    9562, 9563, 9564, 9565, 9566, 9567, 
    9568, 9569, 9570, 9571, 9572, 9573, 
    9574, 9575, 9576, 9577, 9578, 9579, 
    9580
  ) 
GROUP BY 
  q_products_categories.product_id

Query time 0.00086

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "120.41"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "q_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 34,
            "rows_produced_per_join": 34,
            "filtered": "100.00",
            "index_condition": "(`portal`.`q_products_categories`.`product_id` in (9549,9550,9551,9552,9553,9554,9555,9556,9557,9558,9559,9560,9561,9562,9563,9564,9565,9566,9567,9568,9569,9570,9571,9572,9573,9574,9575,9576,9577,9578,9579,9580))",
            "cost_info": {
              "read_cost": "72.81",
              "eval_cost": "6.80",
              "prefix_cost": "79.61",
              "data_read_per_join": "544"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        },
        {
          "table": {
            "table_name": "q_categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "portal.q_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 6,
            "filtered": "20.00",
            "cost_info": {
              "read_cost": "34.00",
              "eval_cost": "1.36",
              "prefix_cost": "120.41",
              "data_read_per_join": "17K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "(((`portal`.`q_categories`.`usergroup_ids` = '') or find_in_set(0,`portal`.`q_categories`.`usergroup_ids`) or find_in_set(1,`portal`.`q_categories`.`usergroup_ids`)) and (`portal`.`q_categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids
9549 386M
9550 200M
9551 386M
9552 386M
9553 386M
9554 386M
9555 424,382M
9556 424,382M
9557 382M
9558 386M
9559 200M
9560 195M
9561 195M
9562 195M
9563 195M
9564 195M
9565 195M
9566 195M
9567 195M
9568 195M
9569 195M
9570 195M
9571 301M
9572 195M
9573 551M
9574 195M
9575 195M
9576 195M
9577 195M
9578 195M
9579 402M
9580 402M