SELECT 
  q_products_categories.product_id, 
  GROUP_CONCAT(
    IF(
      q_products_categories.link_type = "M", 
      CONCAT(
        q_products_categories.category_id, 
        "M"
      ), 
      q_products_categories.category_id
    )
  ) AS category_ids, 
  product_position_source.position AS position 
FROM 
  q_products_categories 
  INNER JOIN q_categories ON q_categories.category_id = q_products_categories.category_id 
  AND (
    q_categories.usergroup_ids = '' 
    OR FIND_IN_SET(0, q_categories.usergroup_ids) 
    OR FIND_IN_SET(1, q_categories.usergroup_ids)
  ) 
  AND q_categories.status IN ('A', 'H') 
  LEFT JOIN q_products_categories AS product_position_source ON q_products_categories.product_id = product_position_source.product_id 
  AND product_position_source.category_id = 248 
WHERE 
  q_products_categories.product_id IN (
    10309, 
    10310, 
    10311, 
    10312, 
    10313, 
    10314, 
    10315, 
    10316, 
    10317, 
    10318, 
    10319, 
    10322, 
    10324, 
    10325, 
    10326, 
    1471, 
    1472, 
    1473, 
    1474, 
    1475, 
    1476, 
    1477, 
    1478, 
    1479, 
    1480, 
    1481, 
    1482, 
    1483, 
    1484, 
    1485, 
    1486, 
    1487, 
    1488, 
    1489, 
    1490, 
    1491, 
    1492, 
    1493, 
    1494, 
    1495, 
    1496, 
    1497, 
    1498, 
    1499, 
    1500, 
    1502, 
    1503, 
    1504, 
    1505, 
    1506, 
    1507, 
    1508, 
    1509, 
    1510, 
    1511, 
    1512, 
    1513, 
    1514, 
    1515, 
    1516, 
    1517, 
    1518, 
    1521, 
    1522, 
    1523, 
    1528, 
    1529, 
    1530, 
    1531, 
    1532, 
    1533, 
    1534, 
    1535, 
    1536, 
    1537, 
    1538, 
    1539, 
    1540, 
    1541, 
    1542, 
    1543, 
    1544, 
    1545, 
    1546, 
    1547, 
    1548, 
    1549, 
    1550, 
    1551, 
    1552, 
    1553, 
    1554, 
    1555, 
    1556, 
    1557, 
    1558, 
    1559, 
    1560, 
    1561, 
    1562, 
    1563, 
    1564, 
    1565, 
    1566, 
    1567, 
    1568, 
    1569, 
    1570, 
    1571, 
    1572, 
    1573, 
    1574, 
    1577, 
    1578, 
    1579, 
    1580, 
    1581, 
    1582, 
    1583, 
    1584, 
    1585, 
    1586, 
    1587, 
    1588, 
    1589, 
    1590, 
    1591, 
    1592
  ) 
GROUP BY 
  q_products_categories.product_id

Query time 0.00199

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "622.01"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "q_products_categories",
            "access_type": "range",
            "possible_keys": [
              "PRIMARY",
              "pt"
            ],
            "key": "pt",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "rows_examined_per_scan": 130,
            "rows_produced_per_join": 130,
            "filtered": "100.00",
            "index_condition": "(`portal`.`q_products_categories`.`product_id` in (10309,10310,10311,10312,10313,10314,10315,10316,10317,10318,10319,10322,10324,10325,10326,1471,1472,1473,1474,1475,1476,1477,1478,1479,1480,1481,1482,1483,1484,1485,1486,1487,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,1515,1516,1517,1518,1521,1522,1523,1528,1529,1530,1531,1532,1533,1534,1535,1536,1537,1538,1539,1540,1541,1542,1543,1544,1545,1546,1547,1548,1549,1550,1551,1552,1553,1554,1555,1556,1557,1558,1559,1560,1561,1562,1563,1564,1565,1566,1567,1568,1569,1570,1571,1572,1573,1574,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,1591,1592))",
            "cost_info": {
              "read_cost": "284.01",
              "eval_cost": "26.00",
              "prefix_cost": "310.01",
              "data_read_per_join": "2K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "link_type"
            ]
          }
        },
        {
          "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",
              "portal.q_products_categories.product_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 130,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "130.00",
              "eval_cost": "26.00",
              "prefix_cost": "466.01",
              "data_read_per_join": "2K"
            },
            "used_columns": [
              "product_id",
              "category_id",
              "position"
            ]
          }
        },
        {
          "table": {
            "table_name": "q_categories",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "c_status",
              "p_category_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id"
            ],
            "key_length": "3",
            "ref": [
              "portal.q_products_categories.category_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 26,
            "filtered": "20.00",
            "cost_info": {
              "read_cost": "130.00",
              "eval_cost": "5.20",
              "prefix_cost": "622.01",
              "data_read_per_join": "68K"
            },
            "used_columns": [
              "category_id",
              "usergroup_ids",
              "status"
            ],
            "attached_condition": "(((`portal`.`q_categories`.`usergroup_ids` = '') or find_in_set(0,`portal`.`q_categories`.`usergroup_ids`) or find_in_set(1,`portal`.`q_categories`.`usergroup_ids`)) and (`portal`.`q_categories`.`status` in ('A','H')))"
          }
        }
      ]
    }
  }
}

Result

product_id category_ids position
1471 598M
1472 598M
1473 598M
1474 598M
1475 598M
1476 598M
1477 598M
1478 598M
1479 598M
1480 598M
1481 364M
1482 364M
1483 364M
1484 598M
1485 598M
1486 598M
1487 598M
1488 598M
1489 391M
1490 391M
1491 391M
1492 391M
1493 391M
1494 391M
1495 391M
1496 391M
1497 391M
1498 391M
1499 248M 0
1500 248M 0
1502 248M 0
1503 266M
1504 266M
1505 266M
1506 266M
1507 266M
1508 266M
1509 266M
1510 266M
1511 266M
1512 266M
1513 266M
1514 266M
1515 266M
1516 266M
1517 266M
1518 266M
1521 91,248M 0
1522 323M
1523 323,248M 0
1528 329M
1529 329M
1530 329M
1531 329M
1532 329M
1533 329M
1534 352M
1535 352M
1536 392M
1537 392M
1538 392M
1539 392M
1540 392M
1541 392M
1542 392M
1543 392M
1544 392M
1545 392M
1546 392M
1547 392M
1548 290M
1549 290M
1550 248M 0
1551 546,290M
1552 546,290M
1553 546M
1554 546,290M
1555 546,290M
1556 546,290M
1557 546,290M
1558 546,290M
1559 546M
1560 546M
1561 546M
1562 248M 0
1563 248M 0
1564 248M 0
1565 248M 0
1566 248M 0
1567 546M
1568 290M
1569 290M
1570 290M
1571 290M
1572 290M
1573 290M
1574 290M
1577 393M
1578 393M
1579 393M
1580 393M
1581 167,276M
1582 276M
1583 276M
1584 276M
1585 276M
1586 393M
1587 167,276M
1588 248M 0
1589 167,276M
1590 393M
1591 393M
1592 167,393M
10309 290M
10310 290M
10311 290M
10312 290M
10313 290M
10314 290M
10315 290M
10316 290M
10317 546M
10318 290M
10319 290M
10322 290M
10324 290M
10325 290M
10326 290M