SELECT 
  company_descriptions.*, 
  companies.*, 
  cscart_vendor_plan_descriptions.plan, 
  AVG(
    cscart_discussion_rating.rating_value
  ) AS average_rating, 
  CONCAT(
    companies.company_id, 
    '_', 
    IF (
      cscart_discussion_rating.thread_id, 
      cscart_discussion_rating.thread_id, 
      '0'
    )
  ) AS company_thread_ids 
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 = 'ru' 
  LEFT JOIN cscart_vendor_plan_descriptions ON companies.plan_id = cscart_vendor_plan_descriptions.plan_id 
  AND cscart_vendor_plan_descriptions.lang_code = 'ru' 
  LEFT JOIN cscart_discussion ON cscart_discussion.object_id = companies.company_id 
  AND cscart_discussion.object_type = 'M' 
  LEFT JOIN cscart_discussion_posts ON cscart_discussion_posts.thread_id = cscart_discussion.thread_id 
  AND cscart_discussion_posts.status = 'A' 
  LEFT JOIN cscart_discussion_rating ON cscart_discussion.thread_id = cscart_discussion_rating.thread_id 
  AND cscart_discussion_rating.post_id = cscart_discussion_posts.post_id 
WHERE 
  companies.company_id = 4

Query time 0.01336

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_discussion",
          "access_type": "const",
          "possible_keys": ["object_id"],
          "key": "object_id",
          "key_length": "6",
          "used_key_parts": ["object_id", "object_type"],
          "ref": ["const", "const"],
          "rows": 0,
          "filtered": 0,
          "unique_row_not_found": true
        }
      },
      {
        "table": {
          "table_name": "cscart_discussion_posts",
          "access_type": "const",
          "possible_keys": ["thread_id", "thread_id_2"],
          "rows": 1,
          "filtered": 100
        }
      },
      {
        "table": {
          "table_name": "cscart_discussion_rating",
          "access_type": "const",
          "possible_keys": ["PRIMARY", "thread_id"],
          "rows": 1,
          "filtered": 100
        }
      }
    ]
  }
}

Result

company_id lang_code company_description i18n_company i18n_address i18n_city terms status company address city 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 registered_from_storefront_id agent_type plan_id pre_moderation pre_moderation_edit pre_moderation_edit_vendors robokassa_store_id robokassa_account_number suspend_date grace_period_start last_time_suspended last_debt_notification_time plan average_rating company_thread_ids
4 ru <p><span style="background-color: initial;">ООО "Мегатон"</span></p><h2><span style="background-color: initial;">Описание компании</span></h2><p>ОАО “Мегатон” – компания, специализирующаяся на торговле одеждой и аксессуарами. Более 10 лет она занимает одну из ведущих позиций на российском рынке. В компании ОАО “Мегатон” в настоящий момент насчитывает около 500 торговых точек в более чем 180 городах.</p><p>В нашем магазине одежды любой посетитель найдет то, что ему нужно! Мы делаем все возможное, чтобы вы остались довольны покупками!</p><h2>Реквизиты компании<span style="color: rgb(51, 51, 51); background-color: initial;"></span></h2><table><tbody><tr> <td> <span style="background-color: initial;">Наименование:</span></td> <td> <span style="background-color: initial;">Общество с ограниченной ответственностью «Мегатон», ООО «Мегатон»</span></td></tr><tr><td>Юридический адрес:</td> <td>г. Череповец, ул. Молодежная д. 7 </td></tr><tr><td>Фактический адрес:</td> <td><p> г. Череповец, ул. Молодежная д. 7 </p></td></tr><tr><td>ИНН/КПП:</td> <td> <span style="background-color: initial;">3013002771/581101441</span> </td></tr><tr><td> <span style="background-color: initial;">ОГРН:</span></td> <td> <span style="background-color: initial;">110110272331</span> </td></tr></tbody></table><h2>Банковские реквизиты</h2><table><tbody><tr><td> Полное наименование: </td> <td> ООО "Мегатон"</td></tr><tr><td> ИНН: </td> <td> 570912199352 </td></tr><tr><td> ОГРН:</td> <td> 302213182350174</td></tr><tr><td> Банк:</td> <td><p> ОАО "Локо-Банк" </p></td></tr><tr><td> Р/С: </td> <td> 80285110707424730081 </td></tr><tr><td> БИК</td> <td> 031104721</td></tr><tr><td> К/С</td> <td> 55040710505158993081 </td></tr></tbody></table> A Мегатон Молодёжная Череповец VLG RU 162600 megaton@example.com +79094444444 none Y 1404900515 11,1,10,6 0 payment_agent 2 N N N 0 0 0 0 0 Базовый 4_0