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 (
    85479, 86461, 86462, 86737, 86738, 90745, 
    90748, 90751, 90754, 84646, 86604, 
    86673, 83014, 83015, 83546, 83547, 
    90847, 90848, 90926, 90927, 90743, 
    90744, 90746, 90747, 90749, 90750, 
    90752, 90753, 85275, 90742, 82799, 
    82800, 82872, 82873, 82945, 82946, 
    83255, 83257, 83262, 83264, 82797, 
    82870, 82943, 83252, 83259, 84804, 
    84805, 84822, 84823, 84834, 84835, 
    91089, 91175, 91230, 83012, 83013, 
    83544, 83545, 90845, 90846, 90924, 
    90925, 88895, 90823, 91464, 91465, 
    91468, 91469, 90012, 90740, 90741, 
    84514, 84580, 84884, 84899, 88875, 
    88876, 88877, 88878, 88902, 88903, 
    82798, 82871, 82944, 83253, 83260, 
    84798, 84799, 86601, 86602, 86670, 
    86671, 91068, 84878, 82580, 82581
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00251

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "113.83"
    },
    "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": 200,
            "rows_produced_per_join": 200,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "20.33",
              "eval_cost": "20.00",
              "prefix_cost": "40.33",
              "data_read_per_join": "3K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (85479,86461,86462,86737,86738,90745,90748,90751,90754,84646,86604,86673,83014,83015,83546,83547,90847,90848,90926,90927,90743,90744,90746,90747,90749,90750,90752,90753,85275,90742,82799,82800,82872,82873,82945,82946,83255,83257,83262,83264,82797,82870,82943,83252,83259,84804,84805,84822,84823,84834,84835,91089,91175,91230,83012,83013,83544,83545,90845,90846,90924,90925,88895,90823,91464,91465,91468,91469,90012,90740,90741,84514,84580,84884,84899,88875,88876,88877,88878,88902,88903,82798,82871,82944,83253,83260,84798,84799,86601,86602,86670,86671,91068,84878,82580,82581))"
          }
        },
        {
          "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": "50.00",
              "eval_cost": "1.00",
              "prefix_cost": "110.33",
              "data_read_per_join": "26K"
            },
            "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.50",
              "eval_cost": "1.00",
              "prefix_cost": "113.83",
              "data_read_per_join": "160"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
82580 7170,7191M 0
82581 7170,7191M 0
82797 7170,7191M 0
82798 7170,7191M 0
82799 7170,7191M 0
82800 7170,7191M 0
82870 7170,7191M 0
82871 7170,7191M 0
82872 7170,7191M 0
82873 7170,7191M 0
82943 7170,7191M 0
82944 7170,7191M 0
82945 7170,7191M 0
82946 7170,7191M 0
83012 7170,7191M 0
83013 7170,7191M 0
83014 7170,7191M 0
83015 7170,7191M 0
83252 7170,7191M 0
83253 7170,7191M 0
83255 7170,7191M 0
83257 7170,7191M 0
83259 7170,7191M 0
83260 7170,7191M 0
83262 7170,7191M 0
83264 7170,7191M 0
83544 7170,7191M 0
83545 7170,7191M 0
83546 7170,7191M 0
83547 7170,7191M 0
84514 7170,7191M 0
84580 7170,7191M 0
84646 7170,7191M 0
84798 7170,7191M 0
84799 7170,7191M 0
84804 7170,7191M 0
84805 7170,7191M 0
84822 7170,7191M 0
84823 7170,7191M 0
84834 7170,7191M 0
84835 7170,7191M 0
84878 7170,7191M 0
84884 7170,7191M 0
84899 7170,7191M 0
85275 7170,7191M 0
85479 7170,7191M 0
86461 7170,7191,7310M 0
86462 7170,7191,7310M 0
86601 7170,7191,7310M 0
86602 7170,7191,7310M 0
86604 7170,7191,7310M 0
86670 7170,7191,7310M 0
86671 7170,7191,7310M 0
86673 7170,7191,7310M 0
86737 7170,7191M 0
86738 7170,7191M 0
88875 7170,7191M 0
88876 7170,7191M 0
88877 7170,7191M 0
88878 7170,7191M 0
88895 7170,7191M 0
88902 7170,7191M 0
88903 7170,7191M 0
90012 7170,7191M 0
90740 7170,7191M 0
90741 7170,7191M 0
90742 7170,7191M 0
90743 7170,7191M 0
90744 7170,7191M 0
90745 7170,7191M 0
90746 7170,7191M 0
90747 7170,7191M 0
90748 7170,7191M 0
90749 7170,7191M 0
90750 7170,7191M 0
90751 7170,7191M 0
90752 7170,7191M 0
90753 7170,7191M 0
90754 7170,7191M 0
90823 7170,7191M 0
90845 7191,7170M 0
90846 7191,7170M 0
90847 7191,7170M 0
90848 7191,7170M 0
90924 7191,7170M 0
90925 7191,7170M 0
90926 7191,7170M 0
90927 7191,7170M 0
91068 7191,7170M 0
91089 7191,7170M 0
91175 7191,7170M 0
91230 7191,7170M 0
91464 7191,7170M 0
91465 7191,7170M 0
91468 7191,7170M 0
91469 7191,7170M 0