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 (
    190, 461277, 391037, 391032, 391031, 
    391030, 460955, 242, 243, 116541, 116547, 
    172, 168, 167, 169, 156, 175, 12702, 
    312043, 391029, 246, 312051, 461038, 
    173, 312048, 12712, 391035, 21914, 
    391033, 391036, 391034, 154, 161, 165, 
    166, 163, 155, 460948, 184, 183, 145, 
    12710, 12698, 157, 461039, 461275, 
    391040, 461037
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00144

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.321938807,
    "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": 71,
          "cost": 0.090209915,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (190,461277,391037,391032,391031,391030,460955,242,243,116541,116547,172,168,167,169,156,175,12702,312043,391029,246,312051,461038,173,312048,12712,391035,21914,391033,391036,391034,154,161,165,166,163,155,460948,184,183,145,12710,12698,157,461039,461275,391040,461037)",
          "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.cscart_products_categories.category_id"],
          "loops": 71,
          "rows": 1,
          "cost": 0.06432444,
          "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.cscart_products_categories.product_id"
          ],
          "loops": 71,
          "rows": 1,
          "cost": 0.12166844,
          "filtered": 100
        }
      }
    ]
  }
}

Result

product_id category_ids position
145 179M
154 181M
155 181M
156 181M
157 181M
161 199,198M
163 199,198M
165 199,198M
166 199,198M
167 198,199,197M
168 198,199,197M
169 198,199,197M
172 199M
173 199M
175 199M
183 200M
184 200M
190 200M
242 178M
243 178M
246 199M
12698 166M 0
12702 166M 0
12710 166M 0
12712 166M 0
21914 166M 0
116541 166 0
116547 166 0
312043 166M 0
312048 166M 0
312051 166M 0
391029 478,166M 0
391030 478,166M 0
391031 478,166M 0
391032 478,166M 0
391033 478,166M 0
391034 478,166M 0
391035 478,166M 0
391036 478,166M 0
391037 478,166M 0
391040 479M
460948 200M
460955 478,166M 0
461037 182M
461038 166M 0
461039 182M
461275 193M
461277 196M