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 = 7148 
WHERE 
  cscart_products_categories.product_id IN (
    93890, 93891, 93892, 93893, 94023, 94073, 
    94117, 94119, 94120, 94121, 94122, 
    94123, 94124, 94125, 94126, 94127, 
    94128, 94129, 94130, 94131, 94132, 
    94133, 94134, 94135, 94136, 94137, 
    94138, 94139, 94140, 94141, 94142, 
    94143, 94144, 94145, 94146, 94147, 
    94148, 94149, 94150, 94151, 94152, 
    94153, 94154, 94155, 94156, 94157, 
    94158, 94159, 94160, 94381, 94428, 
    94452, 94453, 94454, 94455, 94456, 
    94457, 94458, 94459, 94460, 94461, 
    94462, 94558, 94559, 94560, 94561, 
    94562, 94563, 94564, 94565, 94566, 
    94567, 94568, 94569, 94570, 94571, 
    94572, 94583, 94584, 94585, 94586, 
    94587, 94588, 94604, 94605, 94606, 
    94607, 94608, 94609, 94610, 94611, 
    94612, 94613, 94614, 94615, 94616
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00108

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "130.30"
    },
    "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": 229,
            "rows_produced_per_join": 229,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "23.24",
              "eval_cost": "22.90",
              "prefix_cost": "46.14",
              "data_read_per_join": "3K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (93890,93891,93892,93893,94023,94073,94117,94119,94120,94121,94122,94123,94124,94125,94126,94127,94128,94129,94130,94131,94132,94133,94134,94135,94136,94137,94138,94139,94140,94141,94142,94143,94144,94145,94146,94147,94148,94149,94150,94151,94152,94153,94154,94155,94156,94157,94158,94159,94160,94381,94428,94452,94453,94454,94455,94456,94457,94458,94459,94460,94461,94462,94558,94559,94560,94561,94562,94563,94564,94565,94566,94567,94568,94569,94570,94571,94572,94583,94584,94585,94586,94587,94588,94604,94605,94606,94607,94608,94609,94610,94611,94612,94613,94614,94615,94616))"
          }
        },
        {
          "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": [
              "nuie_scalesta_net.cscart_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 11,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "57.25",
              "eval_cost": "1.15",
              "prefix_cost": "126.29",
              "data_read_per_join": "29K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status",
              "storefront_id"
            ],
            "attached_condition": "((`nuie_scalesta_net`.`cscart_categories`.`storefront_id` in (0,1)) and ((`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`nuie_scalesta_net`.`cscart_categories`.`usergroup_ids`))) and (`nuie_scalesta_net`.`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",
              "nuie_scalesta_net.cscart_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 11,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "2.86",
              "eval_cost": "1.15",
              "prefix_cost": "130.30",
              "data_read_per_join": "183"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
93890 7241,7309,7346,7208M
93891 7241,7309,7346,7208M
93892 7241,7309,7346,7208M
93893 7241,7309,7346,7208M
94023 7301,7151M
94073 7194M
94117 7183,7283,7167M
94119 7265,7247M
94120 7265,7247M
94121 7265,7247M
94122 7265,7247M
94123 7265,7247M
94124 7265,7247M
94125 7265,7247M
94126 7265,7247M
94127 7265,7247M
94128 7265,7247M
94129 7265,7247M
94130 7265,7247M
94131 7265,7247M
94132 7265,7247M
94133 7265,7247M
94134 7265,7247M
94135 7265,7247M
94136 7265,7247M
94137 7265,7247M
94138 7265,7247M
94139 7265,7247M
94140 7194M
94141 7194M
94142 7194M
94143 7194M
94144 7194M
94145 7194M
94146 7194M
94147 7194M
94148 7194M
94149 7194M
94150 7194M
94151 7194M
94152 7194M
94153 7194M
94154 7194M
94155 7194M
94156 7194M
94157 7194M
94158 7194M
94159 7194M
94160 7194M
94381 7226,7225M
94428 7313,7338,7219M
94452 7341,7342,7343,7157M
94453 7341,7342,7343,7157M
94454 7341,7342,7343,7157M
94455 7341,7342,7343,7157M
94456 7341,7342,7343,7157M
94457 7265,7247M
94458 7341,7342,7343,7157M
94459 7341,7342,7343,7157M
94460 7341,7342,7343,7157M
94461 7341,7342,7343,7157M
94462 7341,7342,7343,7157M
94558 7241,7309,7346,7208M
94559 7241,7309,7346,7208M
94560 7241,7309,7346,7208M
94561 7241,7309,7346,7208M
94562 7241,7309,7346,7208M
94563 7241,7309,7346,7208M
94564 7241,7309,7346,7208M
94565 7241,7309,7346,7208M
94566 7241,7309,7346,7208M
94567 7241,7309,7346,7208M
94568 7241,7309,7346,7208M
94569 7241,7309,7346,7208M
94570 7241,7309,7346,7208M
94571 7241,7309,7346,7208M
94572 7241,7309,7346,7208M
94583 7241,7309,7346,7208M
94584 7241,7309,7346,7208M
94585 7241,7309,7346,7208M
94586 7241,7309,7346,7208M
94587 7241,7309,7346,7208M
94588 7241,7309,7346,7208M
94604 7194M
94605 7194M
94606 7194M
94607 7194M
94608 7194M
94609 7194M
94610 7194M
94611 7194M
94612 7194M
94613 7194M
94614 7194M
94615 7194M
94616 7194M