SELECT 
  cscart_ab__mb_motivation_items.*, 
  cscart_ab__mb_motivation_item_descriptions.name, 
  cscart_ab__mb_motivation_item_descriptions.description, 
  cscart_ab__mb_motivation_item_descriptions.lang_code 
FROM 
  cscart_ab__mb_motivation_items 
  LEFT JOIN cscart_ab__mb_motivation_item_objects as destination_objects_not_exclude ON cscart_ab__mb_motivation_items.motivation_item_id = destination_objects_not_exclude.motivation_item_id 
  AND destination_objects_not_exclude.object_type = 'D' 
  AND cscart_ab__mb_motivation_items.exclude_destinations = "N" 
  LEFT JOIN cscart_ab__mb_motivation_item_objects as destination_objects_exclude ON cscart_ab__mb_motivation_items.motivation_item_id = destination_objects_exclude.motivation_item_id 
  AND destination_objects_exclude.object_type = 'D' 
  AND destination_objects_exclude.object_id IN (1) 
  AND cscart_ab__mb_motivation_items.exclude_destinations = "Y" 
  LEFT JOIN cscart_ab__mb_motivation_item_objects as category_objects_not_exclude ON cscart_ab__mb_motivation_items.motivation_item_id = category_objects_not_exclude.motivation_item_id 
  AND category_objects_not_exclude.object_type = 'C' 
  AND cscart_ab__mb_motivation_items.exclude_categories = "N" 
  LEFT JOIN cscart_ab__mb_motivation_item_objects as category_objects_exclude ON cscart_ab__mb_motivation_items.motivation_item_id = category_objects_exclude.motivation_item_id 
  AND category_objects_exclude.object_type = 'C' 
  AND category_objects_exclude.object_id IN (423) 
  AND cscart_ab__mb_motivation_items.exclude_categories = "Y" 
  LEFT JOIN cscart_ab__mb_motivation_item_objects as product_objects_not_exclude ON cscart_ab__mb_motivation_items.motivation_item_id = product_objects_not_exclude.motivation_item_id 
  AND product_objects_not_exclude.object_type = 'P' 
  AND cscart_ab__mb_motivation_items.exclude_products = "N" 
  LEFT JOIN cscart_ab__mb_motivation_item_objects as product_objects_exclude ON cscart_ab__mb_motivation_items.motivation_item_id = product_objects_exclude.motivation_item_id 
  AND product_objects_exclude.object_type = 'P' 
  AND product_objects_exclude.object_id IN (1482) 
  AND cscart_ab__mb_motivation_items.exclude_products = "Y" 
  INNER JOIN cscart_ab__mb_motivation_item_descriptions ON cscart_ab__mb_motivation_item_descriptions.motivation_item_id = cscart_ab__mb_motivation_items.motivation_item_id 
  AND cscart_ab__mb_motivation_item_descriptions.lang_code = 'en' 
WHERE 
  1 
  AND cscart_ab__mb_motivation_items.status = 'A' 
  AND (
    (
      destination_objects_not_exclude.object_id IN (0, 1) 
      OR destination_objects_not_exclude.object_id IS NULL
    ) 
    AND (
      destination_objects_exclude.motivation_item_id IS NULL
    )
  ) 
  AND (
    (
      category_objects_not_exclude.object_id IN (0, 423) 
      OR category_objects_not_exclude.object_id IS NULL
    ) 
    AND (
      category_objects_exclude.motivation_item_id IS NULL
    )
  ) 
  AND (
    (
      product_objects_not_exclude.object_id IN (0, 1482) 
      OR product_objects_not_exclude.object_id IS NULL
    ) 
    AND (
      product_objects_exclude.motivation_item_id IS NULL
    )
  ) 
  AND cscart_ab__mb_motivation_items.company_id = 1 
GROUP BY 
  cscart_ab__mb_motivation_items.motivation_item_id 
ORDER BY 
  cscart_ab__mb_motivation_items.position asc

Query time 0.00188

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "5.29"
    },
    "ordering_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "grouping_operation": {
        "using_filesort": false,
        "nested_loop": [
          {
            "table": {
              "table_name": "cscart_ab__mb_motivation_items",
              "access_type": "index",
              "possible_keys": [
                "PRIMARY",
                "exc_categories",
                "exc_destinations",
                "exc_products"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "motivation_item_id",
                "company_id"
              ],
              "key_length": "7",
              "rows_examined_per_scan": 5,
              "rows_produced_per_join": 1,
              "filtered": "20.00",
              "cost_info": {
                "read_cost": "1.80",
                "eval_cost": "0.20",
                "prefix_cost": "2.00",
                "data_read_per_join": "400"
              },
              "used_columns": [
                "motivation_item_id",
                "company_id",
                "position",
                "expanded",
                "vendor_edit",
                "status",
                "icon_type",
                "icon_class",
                "icon_color",
                "exclude_categories",
                "exclude_destinations",
                "exclude_products",
                "template_path",
                "template_settings"
              ],
              "attached_condition": "((`eshopuga_upgr_4122`.`cscart_ab__mb_motivation_items`.`company_id` = 1) and (`eshopuga_upgr_4122`.`cscart_ab__mb_motivation_items`.`status` = 'A'))"
            }
          },
          {
            "table": {
              "table_name": "cscart_ab__mb_motivation_item_descriptions",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "motivation_item_id",
                "lang_code"
              ],
              "key_length": "9",
              "ref": [
                "eshopuga_upgr_4122.cscart_ab__mb_motivation_items.motivation_item_id",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 1,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "1.00",
                "eval_cost": "0.20",
                "prefix_cost": "3.20",
                "data_read_per_join": "792"
              },
              "used_columns": [
                "motivation_item_id",
                "lang_code",
                "name",
                "description"
              ]
            }
          },
          {
            "table": {
              "table_name": "destination_objects_not_exclude",
              "access_type": "ref",
              "possible_keys": [
                "PRIMARY",
                "mid_otype"
              ],
              "key": "mid_otype",
              "used_key_parts": [
                "motivation_item_id",
                "object_type"
              ],
              "key_length": "6",
              "ref": [
                "eshopuga_upgr_4122.cscart_ab__mb_motivation_items.motivation_item_id",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 0,
              "filtered": "28.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "1.00",
                "eval_cost": "0.06",
                "prefix_cost": "4.40",
                "data_read_per_join": "4"
              },
              "used_columns": [
                "motivation_item_id",
                "object_id",
                "object_type"
              ],
              "attached_condition": "(<if>(found_match(destination_objects_not_exclude), ((`eshopuga_upgr_4122`.`destination_objects_not_exclude`.`object_id` in (0,1)) or isnull(`eshopuga_upgr_4122`.`destination_objects_not_exclude`.`object_id`)), true) and <if>(is_not_null_compl(destination_objects_not_exclude), (`eshopuga_upgr_4122`.`cscart_ab__mb_motivation_items`.`exclude_destinations` = 'N'), true))"
            }
          },
          {
            "table": {
              "table_name": "destination_objects_exclude",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "mid_otype"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "motivation_item_id",
                "object_id",
                "object_type"
              ],
              "key_length": "9",
              "ref": [
                "eshopuga_upgr_4122.cscart_ab__mb_motivation_items.motivation_item_id",
                "const",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 0,
              "filtered": "100.00",
              "not_exists": true,
              "using_index": true,
              "cost_info": {
                "read_cost": "0.28",
                "eval_cost": "0.06",
                "prefix_cost": "4.74",
                "data_read_per_join": "4"
              },
              "used_columns": [
                "motivation_item_id",
                "object_id",
                "object_type"
              ],
              "attached_condition": "(<if>(found_match(destination_objects_exclude), isnull(`eshopuga_upgr_4122`.`destination_objects_exclude`.`motivation_item_id`), true) and <if>(is_not_null_compl(destination_objects_exclude), (`eshopuga_upgr_4122`.`cscart_ab__mb_motivation_items`.`exclude_destinations` = 'Y'), true))"
            }
          },
          {
            "table": {
              "table_name": "category_objects_not_exclude",
              "access_type": "ref",
              "possible_keys": [
                "PRIMARY",
                "mid_otype"
              ],
              "key": "mid_otype",
              "used_key_parts": [
                "motivation_item_id",
                "object_type"
              ],
              "key_length": "6",
              "ref": [
                "eshopuga_upgr_4122.cscart_ab__mb_motivation_items.motivation_item_id",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 0,
              "filtered": "28.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "0.28",
                "eval_cost": "0.02",
                "prefix_cost": "5.07",
                "data_read_per_join": "1"
              },
              "used_columns": [
                "motivation_item_id",
                "object_id",
                "object_type"
              ],
              "attached_condition": "(<if>(found_match(category_objects_not_exclude), ((`eshopuga_upgr_4122`.`category_objects_not_exclude`.`object_id` in (0,423)) or isnull(`eshopuga_upgr_4122`.`category_objects_not_exclude`.`object_id`)), true) and <if>(is_not_null_compl(category_objects_not_exclude), (`eshopuga_upgr_4122`.`cscart_ab__mb_motivation_items`.`exclude_categories` = 'N'), true))"
            }
          },
          {
            "table": {
              "table_name": "category_objects_exclude",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "mid_otype"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "motivation_item_id",
                "object_id",
                "object_type"
              ],
              "key_length": "9",
              "ref": [
                "eshopuga_upgr_4122.cscart_ab__mb_motivation_items.motivation_item_id",
                "const",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 0,
              "filtered": "100.00",
              "not_exists": true,
              "using_index": true,
              "cost_info": {
                "read_cost": "0.08",
                "eval_cost": "0.02",
                "prefix_cost": "5.17",
                "data_read_per_join": "1"
              },
              "used_columns": [
                "motivation_item_id",
                "object_id",
                "object_type"
              ],
              "attached_condition": "(<if>(found_match(category_objects_exclude), isnull(`eshopuga_upgr_4122`.`category_objects_exclude`.`motivation_item_id`), true) and <if>(is_not_null_compl(category_objects_exclude), (`eshopuga_upgr_4122`.`cscart_ab__mb_motivation_items`.`exclude_categories` = 'Y'), true))"
            }
          },
          {
            "table": {
              "table_name": "product_objects_not_exclude",
              "access_type": "ref",
              "possible_keys": [
                "PRIMARY",
                "mid_otype"
              ],
              "key": "mid_otype",
              "used_key_parts": [
                "motivation_item_id",
                "object_type"
              ],
              "key_length": "6",
              "ref": [
                "eshopuga_upgr_4122.cscart_ab__mb_motivation_items.motivation_item_id",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 0,
              "filtered": "28.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "0.08",
                "eval_cost": "0.00",
                "prefix_cost": "5.26",
                "data_read_per_join": "0"
              },
              "used_columns": [
                "motivation_item_id",
                "object_id",
                "object_type"
              ],
              "attached_condition": "(<if>(found_match(product_objects_not_exclude), ((`eshopuga_upgr_4122`.`product_objects_not_exclude`.`object_id` in (0,1482)) or isnull(`eshopuga_upgr_4122`.`product_objects_not_exclude`.`object_id`)), true) and <if>(is_not_null_compl(product_objects_not_exclude), (`eshopuga_upgr_4122`.`cscart_ab__mb_motivation_items`.`exclude_products` = 'N'), true))"
            }
          },
          {
            "table": {
              "table_name": "product_objects_exclude",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY",
                "mid_otype"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "motivation_item_id",
                "object_id",
                "object_type"
              ],
              "key_length": "9",
              "ref": [
                "eshopuga_upgr_4122.cscart_ab__mb_motivation_items.motivation_item_id",
                "const",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 0,
              "filtered": "100.00",
              "not_exists": true,
              "using_index": true,
              "cost_info": {
                "read_cost": "0.02",
                "eval_cost": "0.00",
                "prefix_cost": "5.29",
                "data_read_per_join": "0"
              },
              "used_columns": [
                "motivation_item_id",
                "object_id",
                "object_type"
              ],
              "attached_condition": "(<if>(found_match(product_objects_exclude), isnull(`eshopuga_upgr_4122`.`product_objects_exclude`.`motivation_item_id`), true) and <if>(is_not_null_compl(product_objects_exclude), (`eshopuga_upgr_4122`.`cscart_ab__mb_motivation_items`.`exclude_products` = 'Y'), true))"
            }
          }
        ]
      }
    }
  }
}

Result

motivation_item_id company_id position expanded vendor_edit status icon_type icon_class icon_color exclude_categories exclude_destinations exclude_products template_path template_settings name description lang_code
1 1 100 N Y A icon ut2-icon-outline-local_shipping #999999 N N N addons/ab__motivation_block/blocks/components/item_templates/custom_content.tpl a:2:{s:16:"brand_feature_id";s:2:"18";s:19:"tags_items_per_page";s:2:"10";} Delivery <ul><li>&mdash; For City Deliveries - $8</li><li>&mdash; Upcountry Deliveries - from $11</li><li>&mdash; Cake preparation takes 1 to 2 days</li></ul> en
9 1 100 N Y A icon ut2-icon-outline-new_releases #999999 N N N addons/ab__motivation_block/blocks/components/item_templates/custom_content.tpl a:2:{s:16:"brand_feature_id";s:2:"18";s:19:"tags_items_per_page";s:2:"10";} Designed to delight <ul><li class="text-justify">We have a simple goal – delight our customers with fresh flowers and items that are high quality and beautiful. While we may occasionally need to substitute for color or flower variety, we promise that the flowers you receive will be fresh and wow you or your gift recipient.</li></ul> en
2 1 110 N Y A icon ut2-icon-baseline-credit_card #999999 N N N addons/ab__motivation_block/blocks/components/item_templates/custom_content.tpl a:2:{s:16:"brand_feature_id";s:2:"18";s:19:"tags_items_per_page";s:2:"10";} Payment options <ul><li>&mdash; PayPal</li><li>&mdash; Pesapal</li><li>&mdash; Visa and MasterCard</li><li>&mdash; Cash on delivery</li><li>&mdash; Mobile Money - MTN & Airtel</li><li>&mdash; Сashless payments</li><li>&mdash; Invoices</li><li>&mdash; Phone Ordering</li></ul> en
3 1 120 N Y A icon ut2-icon-outline-new_releases #999999 N N N addons/ab__motivation_block/blocks/components/item_templates/custom_content.tpl a:2:{s:16:"brand_feature_id";s:2:"18";s:19:"tags_items_per_page";s:2:"10";} Our advantages <ul><li>&mdash; 7 Days freshness guaranteed</li><li>&mdash; SMS notification</li><li>&mdash; Return and exchange</li><li>&mdash; Different payment methods</li><li>&mdash; Best price</li><li>&mdash; Order by 12 noon for same day delivery.</li><li>&mdash;&nbsp;Include a SPECIAL message with your order.</li></ul> en
4 1 130 N Y A icon ut2-icon-outline-menu #999999 N N N addons/ab__motivation_block/blocks/components/item_templates/product_categories_list.tpl a:1:{s:16:"brand_feature_id";s:2:"18";} Find similar en