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, 
  product_position_source.position AS position 
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') 
  LEFT JOIN q_products_categories AS product_position_source ON q_products_categories.product_id = product_position_source.product_id 
  AND product_position_source.category_id = 190 
WHERE 
  q_products_categories.product_id IN (
    29707, 29709, 29712, 29716, 29718, 29726, 
    29727, 29728, 29732, 29733, 29735, 
    29736, 29737, 29743, 29747, 29748, 
    29754, 29755, 29758, 29761, 29762, 
    29765, 29766, 29769, 29770, 29771, 
    29775, 29780, 29781, 29787
  ) 
GROUP BY 
  q_products_categories.product_id

Query time 0.00100

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "170.61"
    },
    "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": 37,
            "rows_produced_per_join": 37,
            "filtered": "100.00",
            "index_condition": "(`portal`.`q_products_categories`.`product_id` in (29707,29709,29712,29716,29718,29726,29727,29728,29732,29733,29735,29736,29737,29743,29747,29748,29754,29755,29758,29761,29762,29765,29766,29769,29770,29771,29775,29780,29781,29787))",
            "cost_info": {
              "read_cost": "74.41",
              "eval_cost": "7.40",
              "prefix_cost": "81.81",
              "data_read_per_join": "592"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        },
        {
          "table": {
            "table_name": "product_position_source",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id",
              "product_id"
            ],
            "key_length": "6",
            "ref": [
              "const",
              "portal.q_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 37,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "37.00",
              "eval_cost": "7.40",
              "prefix_cost": "126.21",
              "data_read_per_join": "592"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        },
        {
          "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": 7,
            "filtered": "20.00",
            "cost_info": {
              "read_cost": "37.00",
              "eval_cost": "1.48",
              "prefix_cost": "170.61",
              "data_read_per_join": "19K"
            },
            "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 position
29707 419M
29709 419M
29712 419M
29716 193M
29718 419M
29726 204M
29727 195M
29728 420M
29732 419M
29733 419M
29735 419M
29736 419M
29737 419M
29743 193M
29747 419M
29748 419M
29754 419M
29755 193M
29758 192M
29761 193M
29762 420M
29765 195M
29766 419M
29769 204M
29770 419M
29771 419M
29775 419M
29780 429M
29781 419M
29787 419M