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 = 265 
WHERE 
  cscart_products_categories.product_id IN (
    10065, 10066, 10067, 10068, 10069, 10070, 
    10071, 10072, 10073, 10074, 10075, 
    10076, 10077, 10078, 10079, 10080, 
    10081, 10082, 10083, 10084, 10085, 
    10086, 10087, 10088, 10089, 10090, 
    10091, 10092, 10093, 10094, 10095, 
    10096, 10097, 10098, 10099, 10100, 
    10101, 10102, 10103, 10104, 10105, 
    10106, 10107, 10108, 10109, 10110, 
    10111, 10420, 10421, 10422, 10423, 
    10424, 10425, 10426, 10427, 10428, 
    10429, 10430, 10431, 10432, 10433, 
    10434, 10435, 10436, 10437, 10438, 
    10439, 10440, 10441, 10442, 10443, 
    10444, 10445, 10446, 10447, 10448, 
    10449, 10450, 10451, 10452, 10453, 
    10454, 10455, 10456, 10457, 10458, 
    10459, 10460, 10461, 10462, 10463, 
    10464, 10465, 10466, 10467, 10468
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00301

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "68.63"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "1.72"
      },
      "nested_loop": [
        {
          "table": {
            "table_name": "cscart_categories",
            "access_type": "ALL",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "rows_examined_per_scan": 40,
            "rows_produced_per_join": 1,
            "filtered": "4.00",
            "cost_info": {
              "read_cost": "4.54",
              "eval_cost": "0.16",
              "prefix_cost": "4.70",
              "data_read_per_join": "6K"
            },
            "used_columns": [
              "category_id",
              "storefront_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "((`gaseus`.`cscart_categories`.`storefront_id` in (0,1)) and ((`gaseus`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`gaseus`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`gaseus`.`cscart_categories`.`usergroup_ids`))) and (`gaseus`.`cscart_categories`.`status` in ('A','H')))"
          }
        },
        {
          "table": {
            "table_name": "cscart_products_categories",
            "access_type": "ref",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "gaseus.cscart_categories.category_id"
            ],
            "rows_examined_per_scan": 110,
            "rows_produced_per_join": 1,
            "filtered": "0.98",
            "index_condition": "(`gaseus`.`cscart_products_categories`.`product_id` in (10065,10066,10067,10068,10069,10070,10071,10072,10073,10074,10075,10076,10077,10078,10079,10080,10081,10082,10083,10084,10085,10086,10087,10088,10089,10090,10091,10092,10093,10094,10095,10096,10097,10098,10099,10100,10101,10102,10103,10104,10105,10106,10107,10108,10109,10110,10111,10420,10421,10422,10423,10424,10425,10426,10427,10428,10429,10430,10431,10432,10433,10434,10435,10436,10437,10438,10439,10440,10441,10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,10454,10455,10456,10457,10458,10459,10460,10461,10462,10463,10464,10465,10466,10467,10468))",
            "cost_info": {
              "read_cost": "44.00",
              "eval_cost": "0.17",
              "prefix_cost": "66.30",
              "data_read_per_join": "27"
            },
            "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",
              "gaseus.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 1,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "0.43",
              "eval_cost": "0.17",
              "prefix_cost": "66.91",
              "data_read_per_join": "27"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
10065 306M
10066 306M
10067 306M
10068 306M
10069 306M
10070 306M
10071 306M
10072 306M
10073 306M
10074 306M
10075 306M
10076 306M
10077 306M
10078 306M
10079 306M
10080 306M
10081 306M
10082 306M
10083 306M
10084 306M
10085 306M
10086 306M
10087 306M
10088 306M
10089 306M
10090 306M
10091 306M
10092 306M
10093 306M
10094 306M
10095 306M
10096 306M
10097 306M
10098 306M
10099 306M
10100 306M
10101 306M
10102 306M
10103 306M
10104 306M
10105 306M
10106 306M
10107 306M
10108 306M
10109 306M
10110 306M
10111 306M
10420 306M
10421 306M
10422 306M
10423 306M
10424 306M
10425 306M
10426 306M
10427 306M
10428 306M
10429 306M
10430 306M
10431 306M
10432 306M
10433 306M
10434 306M
10435 306M
10436 306M
10437 306M
10438 306M
10439 306M
10440 306M
10441 306M
10442 306M
10443 306M
10444 306M
10445 306M
10446 306M
10447 306M
10448 306M
10449 306M
10450 306M
10451 306M
10452 306M
10453 306M
10454 306M
10455 306M
10456 306M
10457 306M
10458 306M
10459 306M
10460 306M
10461 306M
10462 306M
10463 306M
10464 306M
10465 306M
10466 306M
10467 306M
10468 306M