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 = 7253 
WHERE 
  cscart_products_categories.product_id IN (
    90604, 90610, 90650, 90676, 90692, 90693, 
    90653, 90659, 90618, 90634, 90635, 
    90643, 90595, 90601, 90652, 90658, 
    90594, 90600, 90666, 90608, 84232, 
    84235, 90656, 84236, 90598, 84231, 
    84234, 87864, 84230, 84233, 87844, 
    88096, 87860, 87862, 87842, 87858, 
    87863, 87840, 87833, 87838, 87856, 
    87854, 87834, 87852, 93787, 94372, 
    94373, 94374, 94375, 94376, 94377, 
    94378, 94379, 95399, 95400, 95401, 
    95434, 95435, 95436, 95437, 95438, 
    95439, 95440, 95441, 95704, 95705, 
    95728, 95729, 95730, 95731, 95732, 
    95733, 95734, 95735, 96170, 96171, 
    96172, 96173, 96537, 96559, 96560, 
    96561, 97057, 97058, 97994, 97995, 
    97996, 97997, 97998, 97999, 98000, 
    98496, 98497, 98498, 98499, 98500
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00278

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "109.29"
    },
    "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": 192,
            "rows_produced_per_join": 192,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "19.53",
              "eval_cost": "19.20",
              "prefix_cost": "38.73",
              "data_read_per_join": "3K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ],
            "attached_condition": "(`nuie_scalesta_net`.`cscart_products_categories`.`product_id` in (90604,90610,90650,90676,90692,90693,90653,90659,90618,90634,90635,90643,90595,90601,90652,90658,90594,90600,90666,90608,84232,84235,90656,84236,90598,84231,84234,87864,84230,84233,87844,88096,87860,87862,87842,87858,87863,87840,87833,87838,87856,87854,87834,87852,93787,94372,94373,94374,94375,94376,94377,94378,94379,95399,95400,95401,95434,95435,95436,95437,95438,95439,95440,95441,95704,95705,95728,95729,95730,95731,95732,95733,95734,95735,96170,96171,96172,96173,96537,96559,96560,96561,97057,97058,97994,97995,97996,97997,97998,97999,98000,98496,98497,98498,98499,98500))"
          }
        },
        {
          "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": 9,
            "filtered": "5.00",
            "cost_info": {
              "read_cost": "48.00",
              "eval_cost": "0.96",
              "prefix_cost": "105.93",
              "data_read_per_join": "25K"
            },
            "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": 9,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "2.40",
              "eval_cost": "0.96",
              "prefix_cost": "109.29",
              "data_read_per_join": "153"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
84230 7331,7253M 0
84231 7331,7253M 0
84232 7331,7253M 0
84233 7331,7253M 0
84234 7331,7253M 0
84235 7331,7253M 0
84236 7331,7253M 0
87833 7331,7253M 0
87834 7331,7253M 0
87838 7331,7253M 0
87840 7331,7253M 0
87842 7331,7253M 0
87844 7331,7253M 0
87852 7331,7253M 0
87854 7331,7253M 0
87856 7331,7253M 0
87858 7331,7253M 0
87860 7331,7253M 0
87862 7331,7253M 0
87863 7331,7253M 0
87864 7331,7253M 0
88096 7331,7253M 0
90594 7331,7253M 0
90595 7331,7253M 0
90598 7331,7253M 0
90600 7331,7253M 0
90601 7331,7253M 0
90604 7331,7253M 0
90608 7331,7253M 0
90610 7331,7253M 0
90618 7331,7253M 0
90634 7331,7253M 0
90635 7331,7253M 0
90643 7331,7253M 0
90650 7331,7253M 0
90652 7331,7253M 0
90653 7331,7253M 0
90656 7331,7253M 0
90658 7331,7253M 0
90659 7331,7253M 0
90666 7331,7253M 0
90676 7331,7253M 0
90692 7331,7253M 0
90693 7331,7253M 0
93787 7331,7253M 0
94372 7331,7253M 0
94373 7331,7253M 0
94374 7331,7253M 0
94375 7331,7253M 0
94376 7331,7253M 0
94377 7331,7253M 0
94378 7331,7253M 0
94379 7331,7253M 0
95399 7331,7253M 0
95400 7331,7253M 0
95401 7331,7253M 0
95434 7331,7253M 0
95435 7331,7253M 0
95436 7331,7253M 0
95437 7331,7253M 0
95438 7331,7253M 0
95439 7331,7253M 0
95440 7331,7253M 0
95441 7331,7253M 0
95704 7331,7253M 0
95705 7331,7253M 0
95728 7331,7253M 0
95729 7331,7253M 0
95730 7331,7253M 0
95731 7331,7253M 0
95732 7331,7253M 0
95733 7331,7253M 0
95734 7331,7253M 0
95735 7331,7253M 0
96170 7331,7253M 0
96171 7331,7253M 0
96172 7331,7253M 0
96173 7331,7253M 0
96537 7331,7253M 0
96559 7331,7253M 0
96560 7331,7253M 0
96561 7331,7253M 0
97057 7331,7253M 0
97058 7331,7253M 0
97994 7331,7253M 0
97995 7331,7253M 0
97996 7331,7253M 0
97997 7331,7253M 0
97998 7331,7253M 0
97999 7331,7253M 0
98000 7331,7253M 0
98496 7331,7253M 0
98497 7331,7253M 0
98498 7331,7253M 0
98499 7331,7253M 0
98500 7331,7253M 0