SELECT 
  category_id, 
  parent_id 
FROM 
  jmj_categories 
WHERE 
  parent_id IN(
    20, 26, 9, 8, 19, 10, 21, 30, 25, 11, 22, 
    27, 28, 23, 12, 29, 13, 24, 14, 15, 16, 
    18, 17
  ) 
  AND category_id != 1

Query time 0.00503

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "29.42"
    },
    "table": {
      "table_name": "jmj_categories",
      "access_type": "ALL",
      "possible_keys": [
        "PRIMARY",
        "parent",
        "p_category_id"
      ],
      "rows_examined_per_scan": 120,
      "rows_produced_per_join": 38,
      "filtered": "32.50",
      "cost_info": {
        "read_cost": "21.62",
        "eval_cost": "7.80",
        "prefix_cost": "29.42",
        "data_read_per_join": "151K"
      },
      "used_columns": [
        "category_id",
        "parent_id"
      ],
      "attached_condition": "((`jmj_test`.`jmj_categories`.`parent_id` in (20,26,9,8,19,10,21,30,25,11,22,27,28,23,12,29,13,24,14,15,16,18,17)) and (`jmj_test`.`jmj_categories`.`category_id` <> 1))"
    }
  }
}

Result

category_id parent_id
9 8
20 19
26 25
10 8
21 19
30 25
11 8
22 19
27 25
12 8
23 19
28 25
13 8
24 19
29 25
14 8
15 8
16 8
18 8
17 8