SELECT 
  cscart_products_categories.product_id, 
  GROUP_CONCAT(
    IF(
      cscart_products_categories.link_type = "M", 
      CONCAT(
        cscart_products_categories.category_id, 
        "M"
      ), 
      cscart_products_categories.category_id
    )
  ) AS category_ids, 
  product_position_source.position AS position 
FROM 
  cscart_products_categories 
  INNER JOIN cscart_categories ON cscart_categories.category_id = cscart_products_categories.category_id 
  AND cscart_categories.storefront_id IN (0, 1) 
  AND (
    cscart_categories.usergroup_ids = '' 
    OR FIND_IN_SET(
      0, cscart_categories.usergroup_ids
    ) 
    OR FIND_IN_SET(
      1, cscart_categories.usergroup_ids
    )
  ) 
  AND cscart_categories.status IN ('A', 'H') 
  LEFT JOIN cscart_products_categories AS product_position_source ON cscart_products_categories.product_id = product_position_source.product_id 
  AND product_position_source.category_id = 2601 
WHERE 
  cscart_products_categories.product_id IN (
    431086, 431212, 431369, 431402, 430785, 
    430833, 430987, 431300, 430724, 430941, 
    431081, 431377, 431384, 430733, 431181, 
    431229, 431472, 430956, 431253, 431454, 
    430721, 431387, 431225, 431431, 430682, 
    430951, 431438, 431450, 430716, 431382, 
    431446, 431468, 431401, 431412, 431430, 
    430945, 431143, 431215, 431058, 431170, 
    431294, 431312, 431367, 431460, 430731, 
    431036, 431224, 431259, 431276, 431310, 
    430777, 431332, 431396, 431296, 431298, 
    431414, 431014, 431172, 431207, 431471, 
    431479, 431180, 431233, 431442, 431189, 
    431413, 431455, 431213, 431278, 431351, 
    430970, 430996, 431095, 431299, 431483, 
    431496, 431059, 431075, 431391, 431478, 
    431282, 431436, 431265, 431435, 431489, 
    431232, 431477, 430728, 431449, 431214, 
    431448, 430986, 431379, 431331, 431375, 
    431221, 431323, 431492, 431388, 431475
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00168

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "167.15"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "link_type",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 100,
            "rows_produced_per_join": 100,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "21.15",
              "eval_cost": "20.00",
              "prefix_cost": "41.15",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`webmarco`.`cscart_products_categories`.`product_id` in (431086,431212,431369,431402,430785,430833,430987,431300,430724,430941,431081,431377,431384,430733,431181,431229,431472,430956,431253,431454,430721,431387,431225,431431,430682,430951,431438,431450,430716,431382,431446,431468,431401,431412,431430,430945,431143,431215,431058,431170,431294,431312,431367,431460,430731,431036,431224,431259,431276,431310,430777,431332,431396,431296,431298,431414,431014,431172,431207,431471,431479,431180,431233,431442,431189,431413,431455,431213,431278,431351,430970,430996,431095,431299,431483,431496,431059,431075,431391,431478,431282,431436,431265,431435,431489,431232,431477,430728,431449,431214,431448,430986,431379,431331,431375,431221,431323,431492,431388,431475))"
          }
        },
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "webmarco.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 5,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "100.00",
              "eval_cost": "1.00",
              "prefix_cost": "161.15",
              "data_read_per_join": "29K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`webmarco`.`cscart_categories`.`storefront_id` in (0,1)) and ((`webmarco`.`cscart_categories`.`usergroup_ids` = '') or find_in_set(0,`webmarco`.`cscart_categories`.`usergroup_ids`) or find_in_set(1,`webmarco`.`cscart_categories`.`usergroup_ids`)) and (`webmarco`.`cscart_categories`.`status` in ('A','H')))"
          }
        },
        {
          "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",
              "webmarco.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 5,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "5.00",
              "eval_cost": "1.00",
              "prefix_cost": "167.15",
              "data_read_per_join": "80"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
430682 2601M 0
430716 2601M 0
430721 2601M 0
430724 2601M 0
430728 2601M 0
430731 2601M 0
430733 2601M 0
430777 2601M 0
430785 2601M 0
430833 2601M 0
430941 2601M 0
430945 2601M 0
430951 2601M 0
430956 2601M 0
430970 2601M 0
430986 2601M 0
430987 2601M 0
430996 2601M 0
431014 2601M 0
431036 2601M 0
431058 2601M 0
431059 2601M 0
431075 2601M 0
431081 2601M 0
431086 2601M 0
431095 2601M 0
431143 2601M 0
431170 2601M 0
431172 2601M 0
431180 2601M 0
431181 2601M 0
431189 2601M 0
431207 2601M 0
431212 2601M 0
431213 2601M 0
431214 2601M 0
431215 2601M 0
431221 2601M 0
431224 2601M 0
431225 2601M 0
431229 2601M 0
431232 2601M 0
431233 2601M 0
431253 2601M 0
431259 2601M 0
431265 2601M 0
431276 2601M 0
431278 2601M 0
431282 2601M 0
431294 2601M 0
431296 2601M 0
431298 2601M 0
431299 2601M 0
431300 2601M 0
431310 2601M 0
431312 2601M 0
431323 2601M 0
431331 2601M 0
431332 2601M 0
431351 2601M 0
431367 2601M 0
431369 2601M 0
431375 2601M 0
431377 2601M 0
431379 2601M 0
431382 2601M 0
431384 2601M 0
431387 2601M 0
431388 2601M 0
431391 2601M 0
431396 2601M 0
431401 2601M 0
431402 2601M 0
431412 2601M 0
431413 2601M 0
431414 2601M 0
431430 2601M 0
431431 2601M 0
431435 2601M 0
431436 2601M 0
431438 2601M 0
431442 2601M 0
431446 2601M 0
431448 2601M 0
431449 2601M 0
431450 2601M 0
431454 2601M 0
431455 2601M 0
431460 2601M 0
431468 2601M 0
431471 2601M 0
431472 2601M 0
431475 2601M 0
431477 2601M 0
431478 2601M 0
431479 2601M 0
431483 2601M 0
431489 2601M 0
431492 2601M 0
431496 2601M 0