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 = 7191 
WHERE 
  cscart_products_categories.product_id IN (
    89853, 89925, 91491, 85856, 85857, 85866, 
    85867, 85053, 85139, 85185, 85231, 
    90002, 84628, 82801, 82874, 82947, 
    85051, 85137, 85183, 85229, 89802, 
    89854, 89926, 91078, 91079, 91492, 
    82584, 82585, 85047, 85052, 85138, 
    85184, 85230, 85045, 85846, 85847, 
    82860, 82861, 82933, 82934, 83006, 
    83007, 83290, 83292, 83297, 83299, 
    84806, 84807, 84824, 84825, 84836, 
    84837, 91096, 91182, 91237, 84647, 
    89794, 89795, 89846, 89847, 89918, 
    89919, 91485, 91486, 82582, 82858, 
    82931, 83004, 83287, 83294, 85046, 
    86467, 86468, 86743, 86744, 82802, 
    82875, 82948, 82714, 82715, 83304, 
    83306, 84800, 84801, 86465, 86741, 
    89751, 89752, 91072, 82859, 82932, 
    83005, 83288, 83295, 89792, 89793
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00140

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "121.78"
    },
    "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": 214,
            "rows_produced_per_join": 214,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "21.74",
              "eval_cost": "21.40",
              "prefix_cost": "43.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 (89853,89925,91491,85856,85857,85866,85867,85053,85139,85185,85231,90002,84628,82801,82874,82947,85051,85137,85183,85229,89802,89854,89926,91078,91079,91492,82584,82585,85047,85052,85138,85184,85230,85045,85846,85847,82860,82861,82933,82934,83006,83007,83290,83292,83297,83299,84806,84807,84824,84825,84836,84837,91096,91182,91237,84647,89794,89795,89846,89847,89918,89919,91485,91486,82582,82858,82931,83004,83287,83294,85046,86467,86468,86743,86744,82802,82875,82948,82714,82715,83304,83306,84800,84801,86465,86741,89751,89752,91072,82859,82932,83005,83288,83295,89792,89793))"
          }
        },
        {
          "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": 10,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "53.50",
              "eval_cost": "1.07",
              "prefix_cost": "118.04",
              "data_read_per_join": "27K"
            },
            "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": 10,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "2.68",
              "eval_cost": "1.07",
              "prefix_cost": "121.78",
              "data_read_per_join": "171"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
82582 7170,7191M 0
82584 7170,7191M 0
82585 7170,7191M 0
82714 7170,7191M 0
82715 7170,7191M 0
82801 7170,7191M 0
82802 7170,7191M 0
82858 7170,7191M 0
82859 7170,7191M 0
82860 7170,7191M 0
82861 7170,7191M 0
82874 7170,7191M 0
82875 7170,7191M 0
82931 7170,7191M 0
82932 7170,7191M 0
82933 7170,7191M 0
82934 7170,7191M 0
82947 7170,7191M 0
82948 7170,7191M 0
83004 7170,7191M 0
83005 7170,7191M 0
83006 7170,7191M 0
83007 7170,7191M 0
83287 7170,7191M 0
83288 7170,7191M 0
83290 7170,7191M 0
83292 7170,7191M 0
83294 7170,7191M 0
83295 7170,7191M 0
83297 7170,7191M 0
83299 7170,7191M 0
83304 7170,7191M 0
83306 7170,7191M 0
84628 7170,7191M 0
84647 7170,7191M 0
84800 7170,7191M 0
84801 7170,7191M 0
84806 7170,7191M 0
84807 7170,7191M 0
84824 7170,7191M 0
84825 7170,7191M 0
84836 7170,7191M 0
84837 7170,7191M 0
85045 7170,7191,7310M 0
85046 7170,7191,7310M 0
85047 7170,7191,7310M 0
85051 7170,7191,7310M 0
85052 7170,7191,7310M 0
85053 7170,7191,7310M 0
85137 7170,7191,7310M 0
85138 7170,7191,7310M 0
85139 7170,7191,7310M 0
85183 7170,7191,7310M 0
85184 7170,7191,7310M 0
85185 7170,7191,7310M 0
85229 7170,7191,7310M 0
85230 7170,7191,7310M 0
85231 7170,7191,7310M 0
85846 7170,7191M 0
85847 7170,7191M 0
85856 7170,7191M 0
85857 7170,7191M 0
85866 7170,7191M 0
85867 7170,7191M 0
86465 7170,7191,7310M 0
86467 7170,7191,7310M 0
86468 7170,7191,7310M 0
86741 7170,7191M 0
86743 7170,7191M 0
86744 7170,7191M 0
89751 7170,7191M 0
89752 7170,7191M 0
89792 7170,7191M 0
89793 7170,7191M 0
89794 7170,7191M 0
89795 7170,7191M 0
89802 7170,7191M 0
89846 7170,7191M 0
89847 7170,7191M 0
89853 7170,7191M 0
89854 7170,7191M 0
89918 7170,7191,7310M 0
89919 7170,7191,7310M 0
89925 7170,7191,7310M 0
89926 7170,7191,7310M 0
90002 7170,7191M 0
91072 7191,7170M 0
91078 7191,7170M 0
91079 7191,7170M 0
91096 7191,7170M 0
91182 7191,7170M 0
91237 7191,7170M 0
91485 7191,7170M 0
91486 7191,7170M 0
91491 7191,7170M 0
91492 7191,7170M 0