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, 
  vd.description AS vendor_description, 
  vd.status as vendor_status 
FROM 
  cscart_ab__mb_motivation_items 
  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 (4936) 
  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 (276713) 
  AND cscart_ab__mb_motivation_items.exclude_products = "Y" 
  LEFT JOIN cscart_ab__mb_vendors_descriptions AS vd ON vd.motivation_item_id = cscart_ab__mb_motivation_items.motivation_item_id 
  AND vd.company_id = 137 
  AND vd.lang_code = 'en' 
  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 (
    cscart_ab__mb_motivation_items.usergroup_ids = '' 
    OR FIND_IN_SET(
      0, cscart_ab__mb_motivation_items.usergroup_ids
    ) 
    OR FIND_IN_SET(
      1, cscart_ab__mb_motivation_items.usergroup_ids
    )
  ) 
  AND (
    (
      category_objects_not_exclude.object_id IN (0, 4936) 
      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, 276713) 
      OR product_objects_not_exclude.object_id IS NULL
    ) 
    AND (
      product_objects_exclude.motivation_item_id IS NULL
    )
  ) 
  AND cscart_ab__mb_motivation_items.storefront_id = 1 
GROUP BY 
  cscart_ab__mb_motivation_items.motivation_item_id 
ORDER BY 
  cscart_ab__mb_motivation_items.position asc

Query time 0.00407

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "6.95"
    },
    "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_products"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "motivation_item_id",
                "storefront_id"
              ],
              "key_length": "7",
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 1,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "0.25",
                "eval_cost": "0.10",
                "prefix_cost": "0.35",
                "data_read_per_join": "1K"
              },
              "used_columns": [
                "motivation_item_id",
                "storefront_id",
                "position",
                "expanded_desktop",
                "expanded_tablet",
                "expanded_mobile",
                "vendor_edit",
                "status",
                "icon_type",
                "icon_class",
                "icon_color",
                "exclude_destinations",
                "exclude_products",
                "exclude_categories",
                "template_path",
                "template_settings",
                "usergroup_ids"
              ],
              "attached_condition": "((`s2cart`.`cscart_ab__mb_motivation_items`.`storefront_id` = 1) and (`s2cart`.`cscart_ab__mb_motivation_items`.`status` = 'A') and ((`s2cart`.`cscart_ab__mb_motivation_items`.`usergroup_ids` = '') or (0 <> find_in_set(0,`s2cart`.`cscart_ab__mb_motivation_items`.`usergroup_ids`)) or (0 <> find_in_set(1,`s2cart`.`cscart_ab__mb_motivation_items`.`usergroup_ids`))))"
            }
          },
          {
            "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": [
                "s2cart.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.10",
                "prefix_cost": "1.45",
                "data_read_per_join": "792"
              },
              "used_columns": [
                "motivation_item_id",
                "lang_code",
                "name",
                "description"
              ]
            }
          },
          {
            "table": {
              "table_name": "category_objects_not_exclude",
              "access_type": "ref",
              "possible_keys": [
                "PRIMARY",
                "mid_otype"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "motivation_item_id"
              ],
              "key_length": "3",
              "ref": [
                "s2cart.cscart_ab__mb_motivation_items.motivation_item_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 1,
              "filtered": "100.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "1.00",
                "eval_cost": "0.10",
                "prefix_cost": "2.55",
                "data_read_per_join": "16"
              },
              "used_columns": [
                "motivation_item_id",
                "object_id",
                "object_type"
              ],
              "attached_condition": "(<if>(found_match(category_objects_not_exclude), ((`s2cart`.`category_objects_not_exclude`.`object_id` in (0,4936)) or (`s2cart`.`category_objects_not_exclude`.`object_id` is null)), true) and <if>(is_not_null_compl(category_objects_not_exclude), ((`s2cart`.`category_objects_not_exclude`.`object_type` = 'C') and (`s2cart`.`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": [
                "s2cart.cscart_ab__mb_motivation_items.motivation_item_id",
                "const",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 1,
              "filtered": "100.00",
              "not_exists": true,
              "using_index": true,
              "cost_info": {
                "read_cost": "1.00",
                "eval_cost": "0.10",
                "prefix_cost": "3.65",
                "data_read_per_join": "16"
              },
              "used_columns": [
                "motivation_item_id",
                "object_id",
                "object_type"
              ],
              "attached_condition": "(<if>(found_match(category_objects_exclude), (`s2cart`.`category_objects_exclude`.`motivation_item_id` is null), true) and <if>(is_not_null_compl(category_objects_exclude), (`s2cart`.`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": "PRIMARY",
              "used_key_parts": [
                "motivation_item_id"
              ],
              "key_length": "3",
              "ref": [
                "s2cart.cscart_ab__mb_motivation_items.motivation_item_id"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 1,
              "filtered": "100.00",
              "using_index": true,
              "cost_info": {
                "read_cost": "1.00",
                "eval_cost": "0.10",
                "prefix_cost": "4.75",
                "data_read_per_join": "16"
              },
              "used_columns": [
                "motivation_item_id",
                "object_id",
                "object_type"
              ],
              "attached_condition": "(<if>(found_match(product_objects_not_exclude), ((`s2cart`.`product_objects_not_exclude`.`object_id` in (0,276713)) or (`s2cart`.`product_objects_not_exclude`.`object_id` is null)), true) and <if>(is_not_null_compl(product_objects_not_exclude), ((`s2cart`.`product_objects_not_exclude`.`object_type` = 'P') and (`s2cart`.`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": [
                "s2cart.cscart_ab__mb_motivation_items.motivation_item_id",
                "const",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 1,
              "filtered": "100.00",
              "not_exists": true,
              "using_index": true,
              "cost_info": {
                "read_cost": "1.00",
                "eval_cost": "0.10",
                "prefix_cost": "5.85",
                "data_read_per_join": "16"
              },
              "used_columns": [
                "motivation_item_id",
                "object_id",
                "object_type"
              ],
              "attached_condition": "(<if>(found_match(product_objects_exclude), (`s2cart`.`product_objects_exclude`.`motivation_item_id` is null), true) and <if>(is_not_null_compl(product_objects_exclude), (`s2cart`.`cscart_ab__mb_motivation_items`.`exclude_products` = 'Y'), true))"
            }
          },
          {
            "table": {
              "table_name": "vd",
              "access_type": "eq_ref",
              "possible_keys": [
                "PRIMARY"
              ],
              "key": "PRIMARY",
              "used_key_parts": [
                "motivation_item_id",
                "company_id",
                "lang_code"
              ],
              "key_length": "13",
              "ref": [
                "s2cart.cscart_ab__mb_motivation_items.motivation_item_id",
                "const",
                "const"
              ],
              "rows_examined_per_scan": 1,
              "rows_produced_per_join": 1,
              "filtered": "100.00",
              "cost_info": {
                "read_cost": "1.00",
                "eval_cost": "0.10",
                "prefix_cost": "6.95",
                "data_read_per_join": "32"
              },
              "used_columns": [
                "motivation_item_id",
                "company_id",
                "lang_code",
                "description",
                "status"
              ]
            }
          }
        ]
      }
    }
  }
}