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 = 166 
WHERE 
  cscart_products_categories.product_id IN (
    17, 180, 18, 16, 4, 5, 23, 24, 1, 22, 149, 
    190, 189, 3438, 3439, 3440, 3441, 121590, 
    136148, 156245, 169350, 125861, 122330, 
    152282, 146567, 139654, 133778, 149640, 
    159133, 146242, 165619, 121896, 143574, 
    121541, 161803, 151867, 130403, 144684, 
    120464, 144963, 125358, 157738, 154235, 
    137235, 157361, 133193, 157759, 159140, 
    166388, 176206, 135170, 128666, 120703, 
    142104, 162657, 128639, 137145, 145590, 
    160493, 159086, 144380, 153320, 171492, 
    156206
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00192

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.327857853,
    "nested_loop": [
      {
        "table": {
          "table_name": "cscart_products_categories",
          "access_type": "range",
          "possible_keys": ["PRIMARY", "pt"],
          "key": "pt",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "loops": 1,
          "rows": 65,
          "cost": 0.115664525,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (17,180,18,16,4,5,23,24,1,22,149,190,189,3438,3439,3440,3441,121590,136148,156245,169350,125861,122330,152282,146567,139654,133778,149640,159133,146242,165619,121896,143574,121541,161803,151867,130403,144684,120464,144963,125358,157738,154235,137235,157361,133193,157759,159140,166388,176206,135170,128666,120703,142104,162657,128639,137145,145590,160493,159086,144380,153320,171492,156206)",
          "using_index": true
        }
      },
      {
        "table": {
          "table_name": "cscart_categories",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY", "c_status", "p_category_id"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["category_id"],
          "ref": [
            "u985510652_ecartify_abhi.cscart_products_categories.category_id"
          ],
          "loops": 65,
          "rows": 1,
          "cost": 0.0589578,
          "filtered": 100,
          "attached_condition": "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')"
        }
      },
      {
        "table": {
          "table_name": "product_position_source",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY", "pt"],
          "key": "PRIMARY",
          "key_length": "6",
          "used_key_parts": ["category_id", "product_id"],
          "ref": [
            "const",
            "u985510652_ecartify_abhi.cscart_products_categories.product_id"
          ],
          "loops": 65,
          "rows": 1,
          "cost": 0.1113866,
          "filtered": 100
        }
      }
    ]
  }
}

Result

product_id category_ids position
1 190M
4 190M
5 191M
16 194M
17 307,235M
18 194M
22 195M
23 195M
24 195M
149 179M
180 200M
189 200M
190 200M
3438 166M 0
3439 166M 0
3440 166M 0
3441 166M 0
120464 304M
120703 310M
121541 310M
121590 309M
121896 304M
122330 304M
125358 310M
125861 310M
128639 309M
128666 310M
130403 304M
133193 309M
133778 304M
135170 310M
136148 310M
137145 304M
137235 304M
139654 309M
142104 309M
143574 309M
144380 304M
144684 309M
144963 310M
145590 304M
146242 304M
146567 310M
149640 304M
151867 304M
152282 310M
153320 310M
154235 309M
156206 310M
156245 310M
157361 309M
157738 309M
157759 304M
159086 309M
159133 304M
159140 304M
160493 304M
161803 310M
162657 310M
165619 304M
166388 310M
169350 310M
171492 304M
176206 310M