SELECT 
  cscart_ab__category_banners.*, 
  cscart_ab__category_banner_images_and_descr.category_banner, 
  cscart_ab__category_banner_images_and_descr.url, 
  cscart_ab__category_banner_images_and_descr.category_banner_image_id 
FROM 
  cscart_ab__category_banners 
  INNER JOIN cscart_ab__category_banner_images_and_descr ON cscart_ab__category_banner_images_and_descr.category_banner_id = cscart_ab__category_banners.category_banner_id 
  AND cscart_ab__category_banner_images_and_descr.lang_code = 'en' 
  LEFT JOIN cscart_ab__category_banner_categories AS ab__category_banner_categories ON ab__category_banner_categories.category_banner_id = cscart_ab__category_banners.category_banner_id 
  LEFT JOIN cscart_ab__category_banner_categories AS ab__category_banner_categories1 ON ab__category_banner_categories1.category_banner_id = cscart_ab__category_banners.category_banner_id 
  INNER JOIN cscart_images_links AS il ON il.object_type = 'category_banner' 
  AND il.object_id = cscart_ab__category_banner_images_and_descr.category_banner_image_id 
  AND il.pair_id IS NOT NULL 
  AND il.type = 'M' 
WHERE 
  1 
  AND cscart_ab__category_banners.status = 'A' 
  AND cscart_ab__category_banner_images_and_descr.category_banner_image_id IS NOT NULL 
  AND (
    IF(
      cscart_ab__category_banners.from_date, 
      cscart_ab__category_banners.from_date <= 1743814993, 
      1
    ) 
    AND IF(
      cscart_ab__category_banners.to_date, 
      cscart_ab__category_banners.to_date >= 1743814993, 
      1
    )
  ) 
  AND (
    ab__category_banner_categories.category_id = 43210 
    OR (
      ab__category_banner_categories1.category_id IN (43210) 
      AND cscart_ab__category_banners.include_subcategories = 'Y'
    )
  ) 
ORDER BY 
  cscart_ab__category_banner_images_and_descr.category_banner asc

Query time 0.00050

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.013040258,
    "filesort": {
      "sort_key": "cscart_ab__category_banner_images_and_descr.category_banner",
      "temporary_table": {
        "nested_loop": [
          {
            "table": {
              "table_name": "cscart_ab__category_banners",
              "access_type": "ref",
              "possible_keys": ["PRIMARY", "status"],
              "key": "status",
              "key_length": "3",
              "used_key_parts": ["status"],
              "ref": ["const"],
              "loops": 1,
              "rows": 1,
              "cost": 0.00345856,
              "filtered": 100,
              "index_condition": "cscart_ab__category_banners.`status` = 'A'",
              "attached_condition": "if(cscart_ab__category_banners.from_date,cscart_ab__category_banners.from_date <= 1743814993,1) and if(cscart_ab__category_banners.to_date,cscart_ab__category_banners.to_date >= 1743814993,1)"
            }
          },
          {
            "table": {
              "table_name": "cscart_ab__category_banner_images_and_descr",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY", "banner"],
              "key": "banner",
              "key_length": "9",
              "used_key_parts": ["category_banner_id", "lang_code"],
              "ref": [
                "cscart.cscart_ab__category_banners.category_banner_id",
                "const"
              ],
              "loops": 1,
              "rows": 1,
              "cost": 0.00335956,
              "filtered": 100,
              "index_condition": "cscart_ab__category_banner_images_and_descr.category_banner_image_id is not null and cscart_ab__category_banner_images_and_descr.lang_code = 'en'"
            }
          },
          {
            "table": {
              "table_name": "ab__category_banner_categories",
              "access_type": "ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["category_banner_id"],
              "ref": ["cscart.cscart_ab__category_banners.category_banner_id"],
              "loops": 1,
              "rows": 1,
              "cost": 0.00178377,
              "filtered": 100,
              "attached_condition": "trigcond(ab__category_banner_categories.category_id = 43210 or cscart_ab__category_banners.include_subcategories = 'Y')"
            }
          },
          {
            "table": {
              "table_name": "ab__category_banner_categories1",
              "access_type": "ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["category_banner_id"],
              "ref": ["cscart.cscart_ab__category_banners.category_banner_id"],
              "loops": 1,
              "rows": 1,
              "cost": 0.00178377,
              "filtered": 100,
              "attached_condition": "trigcond(ab__category_banner_categories.category_id = 43210 or ab__category_banner_categories1.category_id = 43210 and cscart_ab__category_banners.include_subcategories = 'Y')"
            }
          },
          {
            "table": {
              "table_name": "il",
              "access_type": "ref",
              "possible_keys": ["PRIMARY", "object_id"],
              "key": "object_id",
              "key_length": "81",
              "used_key_parts": ["object_id", "object_type", "type"],
              "ref": [
                "cscart.cscart_ab__category_banner_images_and_descr.category_banner_image_id",
                "const",
                "const"
              ],
              "loops": 1,
              "rows": 1,
              "cost": 0.002024411,
              "filtered": 100,
              "index_condition": "il.object_type = 'category_banner' and il.object_id = cscart_ab__category_banner_images_and_descr.category_banner_image_id and il.`type` = 'M'",
              "attached_condition": "il.pair_id is not null"
            }
          }
        ]
      }
    }
  }
}