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 = 7170 
WHERE 
  cscart_products_categories.product_id IN (
    101431, 101432, 101433, 101434, 101435, 
    101436, 101437, 101438, 101439, 101440, 
    101441, 101442, 101443, 101444, 101445, 
    101446, 101447, 101448, 101449, 101450, 
    101451, 101452, 101453, 101454, 101455, 
    101456, 101457, 101458, 101459, 101460, 
    101461, 101462, 101463, 101464, 101465, 
    101466, 101467, 101468, 101469, 101470, 
    101471, 101472, 101473, 101474, 101475, 
    101476, 101477, 101478, 101479, 101480, 
    101481, 101482, 101483, 101484, 101485, 
    101486, 101487, 101488, 101489, 101490, 
    101491, 101492, 101493, 101494, 101495, 
    101496, 101497, 101498, 101499, 101500, 
    101501, 101502, 101503, 101504, 101505, 
    101506, 101507, 101508, 101626, 101660, 
    101661, 101662, 101663, 101664, 101665, 
    101666, 101667, 101668, 101671, 101746, 
    101747, 101748, 101749, 101750, 101751, 
    101752
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00246

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "54.77"
    },
    "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": 96,
            "rows_produced_per_join": 96,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "9.89",
              "eval_cost": "9.60",
              "prefix_cost": "19.49",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (101431,101432,101433,101434,101435,101436,101437,101438,101439,101440,101441,101442,101443,101444,101445,101446,101447,101448,101449,101450,101451,101452,101453,101454,101455,101456,101457,101458,101459,101460,101461,101462,101463,101464,101465,101466,101467,101468,101469,101470,101471,101472,101473,101474,101475,101476,101477,101478,101479,101480,101481,101482,101483,101484,101485,101486,101487,101488,101489,101490,101491,101492,101493,101494,101495,101496,101497,101498,101499,101500,101501,101502,101503,101504,101505,101506,101507,101508,101626,101660,101661,101662,101663,101664,101665,101666,101667,101668,101671,101746,101747,101748,101749,101750,101751,101752))"
          }
        },
        {
          "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": 4,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "24.00",
              "eval_cost": "0.48",
              "prefix_cost": "53.09",
              "data_read_per_join": "12K"
            },
            "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": 4,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "1.20",
              "eval_cost": "0.48",
              "prefix_cost": "54.77",
              "data_read_per_join": "76"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
101431 7200M
101432 7200M
101433 7200M
101434 7200M
101435 7200M
101436 7200M
101437 7200M
101438 7200M
101439 7200M
101440 7200M
101441 7200M
101442 7200M
101443 7200M
101444 7200M
101445 7200M
101446 7200M
101447 7200M
101448 7200M
101449 7200M
101450 7200M
101451 7200M
101452 7200M
101453 7200M
101454 7200M
101455 7200M
101456 7200M
101457 7200M
101458 7200M
101459 7200M
101460 7200M
101461 7200M
101462 7200M
101463 7200M
101464 7200M
101465 7200M
101466 7200M
101467 7200M
101468 7200M
101469 7200M
101470 7200M
101471 7200M
101472 7200M
101473 7200M
101474 7200M
101475 7200M
101476 7200M
101477 7200M
101478 7200M
101479 7200M
101480 7200M
101481 7200M
101482 7200M
101483 7200M
101484 7200M
101485 7200M
101486 7200M
101487 7200M
101488 7200M
101489 7200M
101490 7200M
101491 7200M
101492 7200M
101493 7200M
101494 7200M
101495 7200M
101496 7200M
101497 7200M
101498 7200M
101499 7200M
101500 7200M
101501 7200M
101502 7200M
101503 7200M
101504 7200M
101505 7200M
101506 7200M
101507 7200M
101508 7201M
101626 7200M
101660 7201M
101661 7201M
101662 7201M
101663 7201M
101664 7201M
101665 7201M
101666 7201M
101667 7201M
101668 7201M
101671 7201M
101746 7201M
101747 7201M
101748 7201M
101749 7201M
101750 7201M
101751 7201M
101752 7201M