SELECT 
  company_descriptions.*, 
  companies.*, 
  cscart_vendor_plan_descriptions.plan, 
  cscart_seo_names.name as seo_name, 
  cscart_seo_names.path as seo_path, 
  CAST(
    AVG(`prd`.`average_rating`) AS DECIMAL(10, 2)
  ) AS average_rating, 
  prd.reviews_count product_reviews_count 
FROM 
  cscart_companies AS companies 
  LEFT JOIN cscart_company_descriptions AS company_descriptions ON company_descriptions.company_id = companies.company_id 
  AND company_descriptions.lang_code = 'vi' 
  LEFT JOIN cscart_vendor_plan_descriptions ON companies.plan_id = cscart_vendor_plan_descriptions.plan_id 
  AND cscart_vendor_plan_descriptions.lang_code = 'vi' 
  LEFT JOIN cscart_seo_names ON cscart_seo_names.object_id = 509 
  AND cscart_seo_names.type = 'm' 
  AND cscart_seo_names.dispatch = '' 
  AND cscart_seo_names.lang_code = 'vi' 
  LEFT JOIN cscart_products p ON p.company_id = companies.company_id 
  LEFT JOIN cscart_product_review_prepared_data prd ON p.product_id = prd.product_id 
WHERE 
  companies.company_id = 509

Query time 0.04567

JSON explain

{
  "query_block": {
    "select_id": 1,
    "const_condition": "1",
    "nested_loop": [
      {
        "table": {
          "table_name": "companies",
          "access_type": "const",
          "possible_keys": ["PRIMARY"],
          "key": "PRIMARY",
          "key_length": "4",
          "used_key_parts": ["company_id"],
          "ref": ["const"],
          "rows": 1,
          "filtered": 100
        }
      },
      {
        "table": {
          "table_name": "company_descriptions",
          "access_type": "const",
          "possible_keys": ["PRIMARY"],
          "key": "PRIMARY",
          "key_length": "10",
          "used_key_parts": ["company_id", "lang_code"],
          "ref": ["const", "const"],
          "rows": 1,
          "filtered": 100
        }
      },
      {
        "table": {
          "table_name": "cscart_vendor_plan_descriptions",
          "access_type": "const",
          "possible_keys": ["PRIMARY"],
          "key": "PRIMARY",
          "key_length": "10",
          "used_key_parts": ["plan_id", "lang_code"],
          "ref": ["const", "const"],
          "rows": 1,
          "filtered": 100
        }
      },
      {
        "table": {
          "table_name": "cscart_seo_names",
          "access_type": "ref",
          "possible_keys": ["PRIMARY", "dispatch"],
          "key": "PRIMARY",
          "key_length": "206",
          "used_key_parts": ["object_id", "type", "dispatch", "lang_code"],
          "ref": ["const", "const", "const", "const"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "trigcond(cscart_seo_names.`type` = 'm' and cscart_seo_names.dispatch = '' and cscart_seo_names.lang_code = 'vi')"
        }
      },
      {
        "block-nl-join": {
          "table": {
            "table_name": "p",
            "access_type": "ALL",
            "rows": 25270,
            "filtered": 100,
            "attached_condition": "p.company_id = 509"
          },
          "buffer_type": "flat",
          "buffer_size": "18Kb",
          "join_type": "BNL",
          "attached_condition": "trigcond(p.company_id = 509)"
        }
      },
      {
        "table": {
          "table_name": "prd",
          "access_type": "ref",
          "possible_keys": ["PRIMARY"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "ref": ["dev_db.p.product_id"],
          "rows": 562,
          "filtered": 100,
          "attached_condition": "trigcond(trigcond(p.product_id is not null))"
        }
      }
    ]
  }
}

Result

company_id lang_code company_description terms status company company_search address city city_id district_id ward_id state country zipcode email phone url storefront secure_storefront entry_page redirect_customer countries_list timestamp shippings logos request_user_id request_account_name request_account_data tax_number pre_moderation pre_moderation_edit pre_moderation_edit_vendors plan_id suspend_date grace_period_start last_time_suspended last_debt_notification_time paypal_commerce_platform_account_id stripe_connect_account_id stripe_connect_account_type sended_email_notify ghn_shop_id verify show_homepage messenger messenger_flag plan seo_name seo_path average_rating product_reviews_count
509 vi <p>HENA Happy Oil là thương hiệu được sáng lập bởi tập hợp những người đam mê tinh dầu và dược liệu. Mong muốn chung của họ chính là trao gửi những sản phẩm tinh dầu chất lượng cao đến với khách hàng. Mỗi sản phẩm đều chứa đựng tinh hoa của cả một vùng miền cùng những lợi ích tuyệt vời đến sức khỏe con người.</p> <p>Với nguồn nguyên liệu chính là những loại thảo mộc, thực vật tại vùng đất Đắk Lắk trù phú, HENA Happy Oil áp dụng mô hình sản xuất tinh dầu khép kín và nhất quán từ khâu thổ nhưỡng, giống cây trồng đến kỹ thuật canh tác. Đảm bảo mọi công đoạn có thể ảnh hưởng đến chất lượng thành phẩm cuối cùng đều được kiểm soát chặt chẽ.</p> <p>Trong suốt quá trình hoạt động, thương hiệu gặp không ít khó khăn từ nguồn cung, đảm bảo tính nhất quán trong chất lượng sản phẩm đến vấn đề giá thành vì phải cân bằng với công sức mà những người nông dân đã bỏ ra. Tuy nhiên, HENA vẫn không ngừng cập nhật, nghiên cứu và cải tiến hơn mỗi ngày, với phương châm tập trung tạo ra sản phẩm tinh dầu với chất lượng nhất. Để trong tương lai, HENA có thể tạo ra nhiều sản phẩm hóa mỹ phẩm có giá trị kinh tế cao hơn, chất lượng tốt hơn cho thị trường trong nước và cả nước ngoài.</p> A Hena happy oil Hena happy oil 15 Nguyễn Kim, phường Tân Thành, Thành phố Buôn Ma Thuột, Đắk Lắk, Vietnam 66 643 24142 ruby.le.2703@gmail.com 0985959918 none Y 1622537263 3,4,5,6,7 0 N N N 1 0 0 0 0 0 0 N N A Y Hoa hồng người bán hena-happy-oil-vi 5.00 0