SELECT 
  categories.category_id, 
  categories.parent_id, 
  categories.id_path, 
  category_descriptions.category, 
  categories.position, 
  categories.status, 
  categories.company_id 
FROM 
  categories 
  LEFT JOIN category_descriptions ON categories.category_id = category_descriptions.category_id 
  AND category_descriptions.lang_code = 'en' 
WHERE 
  1 = 1 
  AND (
    categories.usergroup_ids = '' 
    OR FIND_IN_SET(0, categories.usergroup_ids) 
    OR FIND_IN_SET(1, categories.usergroup_ids)
  ) 
  AND categories.status IN ('A') 
  AND categories.level <= 3 
  AND categories.deleted_at IS NULL 
  AND categories.company_id = 242 
ORDER BY 
  categories.is_trash asc, 
  categories.position asc, 
  category_descriptions.category asc

Query time 0.04092

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "1156.26"
    },
    "ordering_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "nested_loop": [
        {
          "table": {
            "table_name": "categories",
            "access_type": "ref",
            "possible_keys": [
              "c_status",
              "index_categories_on_deleted_at"
            ],
            "key": "index_categories_on_deleted_at",
            "used_key_parts": [
              "deleted_at"
            ],
            "key_length": "6",
            "ref": [
              "const"
            ],
            "rows_examined_per_scan": 10182,
            "rows_produced_per_join": 33,
            "filtered": "0.33",
            "index_condition": "(`goimagine`.`categories`.`deleted_at` is null)",
            "cost_info": {
              "read_cost": "120.75",
              "eval_cost": "3.39",
              "prefix_cost": "1138.95",
              "data_read_per_join": "88K"
            },
            "used_columns": [
              "category_id",
              "parent_id",
              "id_path",
              "level",
              "company_id",
              "usergroup_ids",
              "status",
              "position",
              "is_trash",
              "deleted_at"
            ],
            "attached_condition": "((`goimagine`.`categories`.`company_id` = 242) and ((`goimagine`.`categories`.`usergroup_ids` = '') or (0 <> find_in_set(0,`goimagine`.`categories`.`usergroup_ids`)) or (0 <> find_in_set(1,`goimagine`.`categories`.`usergroup_ids`))) and (`goimagine`.`categories`.`status` = 'A') and (`goimagine`.`categories`.`level` <= 3))"
          }
        },
        {
          "table": {
            "table_name": "category_descriptions",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "category_id",
              "lang_code"
            ],
            "key_length": "9",
            "ref": [
              "goimagine.categories.category_id",
              "const"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 33,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "13.91",
              "eval_cost": "3.39",
              "prefix_cost": "1156.26",
              "data_read_per_join": "154K"
            },
            "used_columns": [
              "category_id",
              "lang_code",
              "category"
            ]
          }
        }
      ]
    }
  }
}

Result

category_id parent_id id_path category position status company_id
23245 23244 23244/23245 121212 0 A 242
23251 0 23251 Category 11 Nov 2024 0 A 242
23244 0 23244 tabkllll000111 0 A 242
23243 18962 18962/23243 talloyd00 XSMax2 0 A 242
21737 16819 16819/21737 Earthy Vibes - March 2023 - Update 6 A 242
17295 16953 16953/17295 Light Switch Covers 9 A 242
9662 9605 16953/9605/9662 Tiny Trinket Dishes 10 A 242
16788 9605 16953/9605/16788 Clocks 11 A 242
14608 9605 16953/9605/14608 Enamel Art 13 A 242
10407 9605 16953/9605/10407 Enamel and Silverware Mini Candle Holders 14 A 242
1329 1328 1328/1329 Garnet - January Birthstone 15 A 242
1123 2410 16952/2410/1123 Tiny + Smallish Earrings 16 A 242
20529 16819 16819/20529 Let’s Refresh - Dec 2022 - Jan 2023 17 A 242
11840 3204 3204/11840 Valentine's Day & Hearts 19 A 242
1326 1328 1328/1326 Amethyst - February Birthstone 20 A 242
687 2410 16952/2410/687 Large Earrings 21 A 242
20534 16819 16819/20534 Winter Wonderland - Nov 2022 22 A 242
1327 1328 1328/1327 Aquamarine or Jade - March Birthstones 23 A 242
18962 0 18962 Under $20 Plus Ultras 24 A 242
20536 16819 16819/20536 Mad for Plaid - Sept 2022 25 A 242
509 2410 16952/2410/509 Stud / Post Earrings 26 A 242
14866 1328 1328/14866 Moonstone - June Birthstone 28 A 242
19037 2410 16952/2410/19037 Small Square Dangles 29 A 242
20533 16819 16819/20533 Let’s Go Retro - July 2022 30 A 242
7460 2410 16952/2410/7460 Enameled Silver or Copper Earrings 31 A 242
9505 1328 1328/9505 Pearls - June 32 A 242
20532 16819 16819/20532 Outdoor Adventures - June 2022 33 A 242
508 2410 16952/2410/508 Clip-On Non-Pierced Earrings 35 A 242
20537 16819 16819/20537 Seeing Rainbows - May 2022 36 A 242
7848 1328 1328/7848 Carnelian - July or August Birthstone 37 A 242
3206 3204 3204/3206 Father's Day 38 A 242
507 2410 16952/2410/507 Dangle Earrings for Pierced Ears 39 A 242
3212 3204 3204/3212 Memorial Day 40 A 242
16952 0 16952 Jewelry 41 A 242
3216 3204 3204/3216 National Knit & Crochet Days 42 A 242
20535 16819 16819/20535 Beyond the Stars - April 2022 43 A 242
1072 2410 16952/2410/1072 Sterling Silver w/ Gemstone Earrings 44 A 242
1330 1328 1328/1330 Peridot or Jade - August Birthstones 46 A 242
3352 2410 16952/2410/3352 Earrings Upcycled from vintage silverplate trays 47 A 242
20530 16819 16819/20530 Very Peri - Jan 2022 48 A 242
1334 1328 1328/1334 Blue Sapphire or Lapis Lazuli - September Birthstones 50 A 242
3210 3204 3204/3210 Halloween 51 A 242
1332 1328 1328/1332 Pink Tourmaline or Opal - October Birthstones 52 A 242
3215 3204 3204/3215 Winter Solstice - Light & Renewal 55 A 242
1333 1328 1328/1333 Blue Topaz or Black Onyx - December Birthstones 56 A 242
3208 3204 3204/3208 Christmas 57 A 242
9500 16952 16952/9500 Rings 58 A 242
2410 16952 16952/2410 Earrings 60 A 242
8997 16952 16952/8997 Bracelets 61 A 242
9604 9605 16953/9605/9604 Tiny Vases for Posies 62 A 242
410 16953 16953/410 Trinket Boxes 65 A 242
511 9605 16953/9605/511 Enamel Lightswitch Covers 66 A 242
510 16953 16953/510 Trinket Dishes 67 A 242
16473 16953 16953/16473 Candle Holders 68 A 242
16819 0 16819 Maker Challenges 69 A 242
8497 2410 16952/2410/8497 Leaf Earrings 70 A 242
1328 0 1328 Gems & Birthstones 71 A 242
16953 0 16953 Home Goods & Décor 72 A 242
3397 16952 16952/3397 Earring/Necklace Sets 73 A 242
9605 16953 16953/9605 Copper Enamel Decor 74 A 242
513 16953 16953/513 Sewing/Knitting/Crochet 75 A 242
1301 16952 16952/1301 Braille Positive Affirmations 77 A 242
540 16952 16952/540 Necklaces Pendants & Charms 78 A 242
23227 23225 23225/23227 child of mother category 80 A 242