SELECT 
  tmall_ab__mb_motivation_items.*, 
  tmall_ab__mb_motivation_item_descriptions.name, 
  tmall_ab__mb_motivation_item_descriptions.description, 
  tmall_ab__mb_motivation_item_descriptions.lang_code, 
  vd.description AS vendor_description, 
  vd.status as vendor_status 
FROM 
  tmall_ab__mb_motivation_items 
  LEFT JOIN tmall_ab__mb_motivation_item_objects as destination_objects_not_exclude ON tmall_ab__mb_motivation_items.motivation_item_id = destination_objects_not_exclude.motivation_item_id 
  AND destination_objects_not_exclude.object_type = 'D' 
  AND tmall_ab__mb_motivation_items.exclude_destinations = "N" 
  LEFT JOIN tmall_ab__mb_motivation_item_objects as destination_objects_exclude ON tmall_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 (7) 
  AND tmall_ab__mb_motivation_items.exclude_destinations = "Y" 
  LEFT JOIN tmall_ab__mb_motivation_item_objects as category_objects_not_exclude ON tmall_ab__mb_motivation_items.motivation_item_id = category_objects_not_exclude.motivation_item_id 
  AND category_objects_not_exclude.object_type = 'C' 
  AND tmall_ab__mb_motivation_items.exclude_categories = "N" 
  LEFT JOIN tmall_ab__mb_motivation_item_objects as category_objects_exclude ON tmall_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 (224) 
  AND tmall_ab__mb_motivation_items.exclude_categories = "Y" 
  LEFT JOIN tmall_ab__mb_motivation_item_objects as product_objects_not_exclude ON tmall_ab__mb_motivation_items.motivation_item_id = product_objects_not_exclude.motivation_item_id 
  AND product_objects_not_exclude.object_type = 'P' 
  AND tmall_ab__mb_motivation_items.exclude_products = "N" 
  LEFT JOIN tmall_ab__mb_motivation_item_objects as product_objects_exclude ON tmall_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 (282) 
  AND tmall_ab__mb_motivation_items.exclude_products = "Y" 
  LEFT JOIN tmall_ab__mb_vendors_descriptions AS vd ON vd.motivation_item_id = tmall_ab__mb_motivation_items.motivation_item_id 
  AND vd.company_id = 1 
  AND vd.lang_code = 'en' 
  INNER JOIN tmall_ab__mb_motivation_item_descriptions ON tmall_ab__mb_motivation_item_descriptions.motivation_item_id = tmall_ab__mb_motivation_items.motivation_item_id 
  AND tmall_ab__mb_motivation_item_descriptions.lang_code = 'en' 
WHERE 
  1 
  AND tmall_ab__mb_motivation_items.status = 'A' 
  AND (
    tmall_ab__mb_motivation_items.usergroup_ids = '' 
    OR FIND_IN_SET(
      0, tmall_ab__mb_motivation_items.usergroup_ids
    ) 
    OR FIND_IN_SET(
      1, tmall_ab__mb_motivation_items.usergroup_ids
    )
  ) 
  AND (
    (
      destination_objects_not_exclude.object_id IN (0, 7) 
      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, 224) 
      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, 282) 
      OR product_objects_not_exclude.object_id IS NULL
    ) 
    AND (
      product_objects_exclude.motivation_item_id IS NULL
    )
  ) 
  AND tmall_ab__mb_motivation_items.storefront_id = 1 
GROUP BY 
  tmall_ab__mb_motivation_items.motivation_item_id 
ORDER BY 
  tmall_ab__mb_motivation_items.position asc

Query time 0.00900

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.04738964,
    "filesort": {
      "sort_key": "tmall_ab__mb_motivation_items.position",
      "temporary_table": {
        "nested_loop": [
          {
            "table": {
              "table_name": "tmall_ab__mb_motivation_items",
              "access_type": "index",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "7",
              "used_key_parts": ["motivation_item_id", "storefront_id"],
              "loops": 1,
              "rows": 4,
              "cost": 0.0115068,
              "filtered": 100,
              "attached_condition": "tmall_ab__mb_motivation_items.storefront_id = 1 and tmall_ab__mb_motivation_items.`status` = 'A' and (tmall_ab__mb_motivation_items.usergroup_ids = '' or find_in_set(0,tmall_ab__mb_motivation_items.usergroup_ids) or find_in_set(1,tmall_ab__mb_motivation_items.usergroup_ids))"
            }
          },
          {
            "table": {
              "table_name": "destination_objects_not_exclude",
              "access_type": "ref",
              "possible_keys": ["PRIMARY", "mid_otype"],
              "key": "mid_otype",
              "key_length": "6",
              "used_key_parts": ["motivation_item_id", "object_type"],
              "ref": [
                "tmall.tmall_ab__mb_motivation_items.motivation_item_id",
                "const"
              ],
              "loops": 4,
              "rows": 1,
              "cost": 0.00471282,
              "filtered": 100,
              "attached_condition": "trigcond(destination_objects_not_exclude.object_id in (0,7) or destination_objects_not_exclude.object_id is null) and trigcond(destination_objects_not_exclude.object_type = 'D' and trigcond(tmall_ab__mb_motivation_items.exclude_destinations = 'N'))",
              "using_index": true
            }
          },
          {
            "table": {
              "table_name": "destination_objects_exclude",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY", "mid_otype"],
              "key": "mid_otype",
              "key_length": "9",
              "used_key_parts": ["motivation_item_id", "object_type", "object_id"],
              "ref": [
                "tmall.tmall_ab__mb_motivation_items.motivation_item_id",
                "const",
                "const"
              ],
              "loops": 4,
              "rows": 1,
              "cost": 0.00431682,
              "filtered": 100,
              "attached_condition": "trigcond(destination_objects_exclude.motivation_item_id is null) and trigcond(destination_objects_exclude.object_type = 'D' and trigcond(tmall_ab__mb_motivation_items.exclude_destinations = 'Y'))",
              "using_index": true,
              "not_exists": true
            }
          },
          {
            "table": {
              "table_name": "tmall_ab__mb_motivation_item_descriptions",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "9",
              "used_key_parts": ["motivation_item_id", "lang_code"],
              "ref": [
                "tmall.tmall_ab__mb_motivation_items.motivation_item_id",
                "const"
              ],
              "loops": 4,
              "rows": 1,
              "cost": 0.00439696,
              "filtered": 100,
              "attached_condition": "tmall_ab__mb_motivation_item_descriptions.lang_code = 'en'"
            }
          },
          {
            "table": {
              "table_name": "category_objects_not_exclude",
              "access_type": "ref",
              "possible_keys": ["PRIMARY", "mid_otype"],
              "key": "mid_otype",
              "key_length": "6",
              "used_key_parts": ["motivation_item_id", "object_type"],
              "ref": [
                "tmall.tmall_ab__mb_motivation_items.motivation_item_id",
                "const"
              ],
              "loops": 4,
              "rows": 1,
              "cost": 0.00471282,
              "filtered": 100,
              "attached_condition": "trigcond(category_objects_not_exclude.object_id in (0,224) or category_objects_not_exclude.object_id is null) and trigcond(category_objects_not_exclude.object_type = 'C' and trigcond(tmall_ab__mb_motivation_items.exclude_categories = 'N'))",
              "using_index": true
            }
          },
          {
            "table": {
              "table_name": "category_objects_exclude",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY", "mid_otype"],
              "key": "mid_otype",
              "key_length": "9",
              "used_key_parts": ["motivation_item_id", "object_type", "object_id"],
              "ref": [
                "tmall.tmall_ab__mb_motivation_items.motivation_item_id",
                "const",
                "const"
              ],
              "loops": 4,
              "rows": 1,
              "cost": 0.00431682,
              "filtered": 100,
              "attached_condition": "trigcond(category_objects_exclude.motivation_item_id is null) and trigcond(category_objects_exclude.object_type = 'C' and trigcond(tmall_ab__mb_motivation_items.exclude_categories = 'Y'))",
              "using_index": true,
              "not_exists": true
            }
          },
          {
            "table": {
              "table_name": "product_objects_not_exclude",
              "access_type": "ref",
              "possible_keys": ["PRIMARY", "mid_otype"],
              "key": "mid_otype",
              "key_length": "6",
              "used_key_parts": ["motivation_item_id", "object_type"],
              "ref": [
                "tmall.tmall_ab__mb_motivation_items.motivation_item_id",
                "const"
              ],
              "loops": 4,
              "rows": 1,
              "cost": 0.00471282,
              "filtered": 100,
              "attached_condition": "trigcond(product_objects_not_exclude.object_id in (0,282) or product_objects_not_exclude.object_id is null) and trigcond(product_objects_not_exclude.object_type = 'P' and trigcond(tmall_ab__mb_motivation_items.exclude_products = 'N'))",
              "using_index": true
            }
          },
          {
            "table": {
              "table_name": "product_objects_exclude",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY", "mid_otype"],
              "key": "mid_otype",
              "key_length": "9",
              "used_key_parts": ["motivation_item_id", "object_type", "object_id"],
              "ref": [
                "tmall.tmall_ab__mb_motivation_items.motivation_item_id",
                "const",
                "const"
              ],
              "loops": 4,
              "rows": 1,
              "cost": 0.00431682,
              "filtered": 100,
              "attached_condition": "trigcond(product_objects_exclude.motivation_item_id is null) and trigcond(product_objects_exclude.object_type = 'P' and trigcond(tmall_ab__mb_motivation_items.exclude_products = 'Y'))",
              "using_index": true,
              "not_exists": true
            }
          },
          {
            "table": {
              "table_name": "vd",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "13",
              "used_key_parts": ["motivation_item_id", "company_id", "lang_code"],
              "ref": [
                "tmall.tmall_ab__mb_motivation_items.motivation_item_id",
                "const",
                "const"
              ],
              "loops": 4,
              "rows": 1,
              "cost": 0.00439696,
              "filtered": 100,
              "attached_condition": "trigcond(vd.lang_code = 'en')"
            }
          }
        ]
      }
    }
  }
}

Result

motivation_item_id storefront_id position expanded_desktop expanded_tablet expanded_mobile vendor_edit status icon_type icon_class icon_color exclude_categories exclude_destinations exclude_products template_path template_settings usergroup_ids name description lang_code vendor_description vendor_status
1 1 100 Y Y Y Y A nothing N N N addons/ab__motivation_block/blocks/components/item_templates/custom_content.tpl 0 Delivery <div class="ab__mb_delivery_type-list"> <div class="ab__mb_delivery_type with_logo"> <img src="images/ab__motivation_block/dhl-delivery.png" width="32" height="32" alt="DHL express"> <div class="ab__mb_delivery_type_description"> <div class="ab__mb_delivery_type_name">DHL express - Fast</div> <div class="ab__mb_delivery_type_time">1 day, Door-to-Door, Courier Delivered</div> </div> <div class="ab__mb_delivery_type_price">from 26$ <span class="ut2-icon-outline-info cm-tooltip" title="This is demo content and does not apply to this company's prices"></span></div> </div> <div class="ab__mb_delivery_type with_logo"> <img src="images/ab__motivation_block/fedex-delivery.png" width="32" height="32" alt="Fedex express"> <div class="ab__mb_delivery_type_description"> <div class="ab__mb_delivery_type_name">Fedex express - International shipments</div> <div class="ab__mb_delivery_type_time">2-3 days, <a href="https://www.fedex.com/en-us/tracking.html" target="_blank" title="Fedex express">Tracking available</a></div> </div> <div class="ab__mb_delivery_type_price">from 14$ <span class="ut2-icon-outline-info cm-tooltip" title="This is demo content and does not apply to this company's prices"></span></div> </div> <div class="ab__mb_delivery_type"> <div class="ab__mb_delivery_type_description"> <div class="ab__mb_delivery_type_name"> <span class="ab__mb_delivery_type_name_link">Pickup at your own expense</span> </div> <div class="ab__mb_delivery_type_time">Tomorrow from 09:00 to 20:00, <a href="?dispatch=store_locator.search" target="_blank">Store location</a></div> </div> <div class="ab__mb_delivery_type_price with_color">Free</div> </div> </div> en
2 1 110 Y Y Y Y A nothing N N N addons/ab__motivation_block/blocks/components/item_templates/custom_content.tpl 0 Payment options <div class="ab__mb_motivation_type-list"> <div class="ab__mb_motivation_type"> <div class="ab__mb_motivation_type_description"> <div class="ab__mb_motivation_type_icons"> <img src="images/ab__motivation_block/icon-apple-pay.svg" width="55" alt="Apple Pay"> <img src="images/ab__motivation_block/icon-google-pay.svg" width="55" alt="Google Pay"> <img src="images/ab__motivation_block/icon-mastercard.svg" width="35" alt="Mastercard"> <img src="images/ab__motivation_block/icon-visa.svg" width="55" alt="Visa"> </div> <div class="ab__mb_motivation_type_name"> <span class="ab__mb_motivation_type_name_link">Cash, bank card, credit/installment payments, cashless payment for legal entities</span> </div> <div class="ab__mb_motivation_type_desc"></div> </div> <div class="ab__mb_motivation_type_more"><a href="payment-and-shipping/" title="" target="_blank">More details</a><span class="ut2-icon-outline-info cm-tooltip" title="This is demo content"></span></div> </div> </div> en
3 1 120 Y Y Y Y A nothing N N N addons/ab__motivation_block/blocks/components/item_templates/custom_content.tpl 0 Warranty and returns <div class="ab__mb_motivation_type-list"> <div class="ab__mb_motivation_type"> <div class="ab__mb_motivation_type_description"> <div class="ab__mb_motivation_type_name"> <span class="ab__mb_motivation_type_name_link">Exchange/return of products of proper quality within <b>14 days</b></span> <span class="ab__mb_motivation_type_name_link">Official manufacturer's warranty: <b>12 months</b></span> </div> </div> <div class="ab__mb_motivation_type_more"><a href="exchange-and-return/" title="" target="_blank">More details</a><span class="ut2-icon-outline-info cm-tooltip" title="This is demo content"></span></div> </div> </div> en