SELECT 
  category_id, 
  parent_id 
FROM 
  categories 
WHERE 
  parent_id IN(
    5150, 5144, 4479, 4476, 2587, 4481, 5146, 
    4478, 5147, 4480, 5145, 4477, 5148, 
    2586, 1399, 1400, 4473, 3876, 3665, 
    2884, 795, 1552, 23123, 1396, 5149, 
    567, 3666, 20810, 588, 1375, 3440
  )

Query time 0.00069

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "8.69"
    },
    "table": {
      "table_name": "categories",
      "access_type": "range",
      "possible_keys": [
        "parent"
      ],
      "key": "parent",
      "used_key_parts": [
        "parent_id"
      ],
      "key_length": "3",
      "rows_examined_per_scan": 40,
      "rows_produced_per_join": 40,
      "filtered": "100.00",
      "using_index": true,
      "cost_info": {
        "read_cost": "4.69",
        "eval_cost": "4.00",
        "prefix_cost": "8.69",
        "data_read_per_join": "104K"
      },
      "used_columns": [
        "category_id",
        "parent_id"
      ],
      "attached_condition": "(`goimagine`.`categories`.`parent_id` in (5150,5144,4479,4476,2587,4481,5146,4478,5147,4480,5145,4477,5148,2586,1399,1400,4473,3876,3665,2884,795,1552,23123,1396,5149,567,3666,20810,588,1375,3440))"
    }
  }
}

Result

category_id parent_id
4476 1399
4477 1399
4478 1399
5144 1400
5145 1400
5146 1400
5147 1400
5148 1400
5150 1400
2587 2586
4479 4473
4480 4473
4481 4473