SELECT 
  a.category_id 
FROM 
  cscart_categories as a 
  LEFT JOIN cscart_categories as b ON b.category_id IN (4338) 
WHERE 
  a.id_path LIKE CONCAT(b.id_path, '/%')

Query time 0.00258

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "1494.60"
    },
    "nested_loop": [
      {
        "table": {
          "table_name": "b",
          "access_type": "const",
          "possible_keys": [
            "PRIMARY",
            "p_category_id"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "category_id"
          ],
          "key_length": "3",
          "ref": [
            "const"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.00",
            "eval_cost": "0.20",
            "prefix_cost": "0.00",
            "data_read_per_join": "5K"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ]
        }
      },
      {
        "table": {
          "table_name": "a",
          "access_type": "index",
          "key": "id_path",
          "used_key_parts": [
            "id_path"
          ],
          "key_length": "767",
          "rows_examined_per_scan": 6988,
          "rows_produced_per_join": 776,
          "filtered": "11.11",
          "using_index": true,
          "cost_info": {
            "read_cost": "97.00",
            "eval_cost": "155.27",
            "prefix_cost": "1494.60",
            "data_read_per_join": "4M"
          },
          "used_columns": [
            "category_id",
            "id_path"
          ],
          "attached_condition": "(`webmarco`.`a`.`id_path` like <cache>(concat('4271/4338','/%')))"
        }
      }
    ]
  }
}

Result

category_id
4354
4370
4380
4391
4400
4410
4416
4425
4434
4454
4462
4469
4482
4489
4496
4506
4514
4520
4541
4547
4409
4421
4432
4440
4449
4464
4483
4498
4512
4467
4485
4509
4523
4533
4543
4554
4583
4600
4620
4631
4651
4674
4700
4709
4723
4737
4747
4753
4769
4777
4785
4799
4819
4835
4557
4566
4568
4578
4586
4594
4604
4611
4624
4636
4605
4614
4623
4637
4645
4661
4668
4679
4686
4697
4698
4860
4876
4890
4905
4966
4984
4999
5056
5103
5126
5144
5154
5167
5195
5211
5221
5235
5248
5261
5274
5279
5288
5295
5300
4527
4538
4546
4558
4576
4584
4596
4610
4625
4643
4659
4670
4683
4691
4703
4712
4718
4724
4732
4739
4744
4750
4756
4761
4770
4796
4804
4814
4821
4826
4780
4790
4811
4836
4845
4852
4863
4869
4879
4843
4856
4874
4889
4912
4929
4939
4719
4956
4975
5085
5100
5112
5122
5107
5121
5131
5142
5157
5165
5175
5181
5187
5198
5202
5212
9625
5219
5229
5236
9389
9390
9428
9429
9433
9612