SELECT 
  company_descriptions.*, 
  companies.*, 
  cscart_vendor_plan_descriptions.plan, 
  cscart_seo_names.name as seo_name, 
  cscart_seo_names.path as seo_path, 
  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 = 'en' 
  LEFT JOIN cscart_vendor_plan_descriptions ON companies.plan_id = cscart_vendor_plan_descriptions.plan_id 
  AND cscart_vendor_plan_descriptions.lang_code = 'en' 
  LEFT JOIN cscart_seo_names ON cscart_seo_names.object_id = 2 
  AND cscart_seo_names.type = 'm' 
  AND cscart_seo_names.dispatch = '' 
  AND cscart_seo_names.lang_code = 'en' 
  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 = 2

Query time 0.00016

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 = 'en')"
        }
      },
      {
        "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": 1,
          "filtered": 100,
          "attached_condition": "trigcond(cscart_discussion.object_type = 'M')"
        }
      },
      {
        "block-nl-join": {
          "table": {
            "table_name": "cscart_discussion_posts",
            "access_type": "ALL",
            "possible_keys": ["thread_id", "thread_id_2"],
            "rows": 4,
            "filtered": 100,
            "attached_condition": "cscart_discussion_posts.`status` = 'A'"
          },
          "buffer_type": "flat",
          "buffer_size": "18Kb",
          "join_type": "BNL",
          "attached_condition": "trigcond(cscart_discussion_posts.thread_id = cscart_discussion.thread_id and cscart_discussion_posts.`status` = 'A')"
        }
      },
      {
        "table": {
          "table_name": "cscart_discussion_rating",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY", "thread_id"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["post_id"],
          "ref": ["ebonza_cscart_test.cscart_discussion_posts.post_id"],
          "rows": 1,
          "filtered": 100,
          "attached_condition": "trigcond(cscart_discussion_rating.thread_id = cscart_discussion.thread_id and trigcond(cscart_discussion_posts.post_id is not null))"
        }
      }
    ]
  }
}

Result

company_id lang_code company_description terms i18n_company i18n_address i18n_city 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 pre_moderation pre_moderation_edit pre_moderation_edit_vendors plan_id suspend_date grace_period_start last_time_suspended last_debt_notification_time stripe_connect_account_id tax_number stripe_connect_account_type registered_from_storefront_id quaderno_id quaderno_access_token quaderno_refresh_token minimum_order_total paypal_commerce_platform_account_id saved_shippings_state plan seo_name seo_path average_rating company_thread_ids
2 en <h3><span style="color:rgb(149,55,52);">We are the only producer of crystal chandeliers in the Slovak Republic. </span></h3> <h5><img src="https://ebonza.eu/images/GLASS%20LPS/1_zrek_priestory_GlassLPS_building.jpg?1617966513288" alt="1_zrek_priestory_GlassLPS_building.jpg?1617966513288" /></h5> <h5><strong></strong></h5> <h5></h5> <h5>We process and smooth raw material of Czech crystal glass BOHEMIA CRYSTAL. Also, we are making chandeliers from original SWAROVSKI ELEMENTS.<br />We utilize the 45-years experience of producing crystal chandeliers and crystal trimmings in Medzilaborce. Lightings are certified by Slovak testing center SR and they have European certificate CE.</h5> <h5>Glass LPS produces more than 1000 types of crystal lightings and  90% of production exports to the EU, Australia, Ukraine and Russia. </h5> <h5></h5> <h5>You can see about 300 types of crystal chandeliers in our showroom in Medzilaborce, the city situated on the east part of Slovakia.</h5> <h5></h5> <h5><img src="https://ebonza.eu/images/GLASS%20LPS/Panorama.jpg?1617966573703" alt="Panorama.jpg?1617966573703" /></h5> <h5>  </h5> <p></p> <h5>In case of bigger orders, we are able to design and install the chandeliers including atypical chandeliers. Some our project you can see below:</h5> <h5></h5> <h5><img src="https://ebonza.eu/images/GLASS%20LPS/Brusenie_DSC7044_catalogue.jpg?1617964714146" style="float:left;width:576px;height:354.219px;margin:0px 10px 10px 0px;" alt="Crystal parts grinding and producing" title="Crystal parts grinding and producing" width="576" height="354" /></h5> <img src="https://ebonza.eu/images/GLASS%20LPS/GlassLPS_mouldering.jpg?1617964875506" style="float:right;width:617px;height:351.766px;margin:0px 0px 10px 10px;" alt="Production photo - Mouldering" title="Production photo - Mouldering" width="617" height="351" /><br /> <h5></h5> <h5></h5> <h5></h5> <h5></h5> <h5></h5> <h5></h5> <h5></h5> <h5></h5> <h5></h5> <h5></h5> <h5></h5> <h5></h5> <h5></h5> <h5></h5> <h5></h5> <h5></h5> <p><br /></p> <p><br /></p> <p><br /></p> <p><br /></p> <p>    </p> <p><strong> </strong></p> <p><img src="https://ebonza.eu/images/GLASS%20LPS/Hotel%20SLONECZNY%20MLYN%2C%20BYDGOSZSC%20POLAND.png?1617966245513" style="width:355px;height:460.266px;float:left;margin:0px 10px 10px 0px;" width="355" height="460" alt="Hotel%20SLONECZNY%20MLYN%2C%20BYDGOSZSC%20POLAND.png?1617966245513" /> <img src="https://ebonza.eu/images/GLASS%20LPS/8_Maria_Terezia_PECHY_castle.jpg?1617967151242" style="width:330px;height:509.641px;margin:0px 0px 10px 10px;float:right;" width="330" height="509" alt="8_Maria_Terezia_PECHY_castle.jpg?1617967151242" /><br /></p> <p><br /></p> <p><img src="https://ebonza.eu/images/GLASS%20LPS/7_Kazachstan_DSC_0060.jpg?1617967316824" style="width:351px;height:623.219px;margin:auto;" width="351" height="623" alt="7_Kazachstan_DSC_0060.jpg?1617967316824" /><br /></p> <p><br /></p> <p><br /></p> <p><br /></p> <p>D<b>elivery policy</b></p> <p>The delivery period is mentioned for each chandelier individually. </p> <p>If not mentioned our process and delivery time is from 7-14 working days for small chandeliers up to 10 kg. </p> <p>For the bigger chandeliers /over 10 kg/, the processing and delivery time could be longer from 14 - 30 working days. The time depends on the type of the chandelier, size and the final shipping destination of the chandelier. </p> <p>  </p> <p>Each chandelier is made after the order. </p> <p>Please before ordering of the chandeliers you can request the production and delivery period via message system on eBonza. We will be glad to assist you and be as precise as possible. </p> <p>  </p> <p><b>Refund Policy</b> </p> <p>Due to the reason that each chandelier is unique and made according to the request from the buyer /it is not the stock item/ we do not accept the returns. It is very hard to sale specific chandeliers with specific colours to other customers. </p> <p>  </p> <p>Please consider carefully before ordering. If you have any questions concerning the quality, specific dimension /except those mentioned for each chandelier/, please contact us before order. </p> <p>  </p> <p>If any specific reason occurred, we accept returns up to 14 days after delivery of the items </p> <p>  </p> <p>The chandeliers are carefully & safely packed. </p> <p>  </p> <p>If any damage of the package during the transport, please write the written claim with transport or shipping company immediately when the parcel will arrive and send us a copy of it. We will contact the shipping company and solve the problem with it. We will send the replacement of each piece damaged during transportation. If there is any piece of the chandelier damaged during the transportation process, please write us the number of the item with the photo, to be sure to send you the correct piece. </p> <p>We are adding with the parcel also a few spare parts to each chandelier to have a possible replacement in the future. </p> <p>  </p> <p>The chandeliers are delivered in disassembly status. That means the buyer needs to do the assembling of the arms, crystals of the chandeliers. </p> <p>We recommend using a professional electrician to install the chandelier or lamps on the wall or ceiling to avoid the damages on the electric cables or chandeliers arms. </p> <p>If any damaged occurs during the installation and you will send us the complaint, please enclose also the installation certificate of the company which installed the chandeliers. We are not responsible for such damages. We are happy to send you a replacement, but we will ask the payment for it /damaged part + delivery cost/. </p> <p>  </p> <p>The shop address for returns: </p> <p>Glass LPS Ltd. </p> <p>Dobrianskeho 56 </p> <p>068 01 Medzilaborce </p> <p>Slovak Republic </p> <p>  </p> <p>  </p> <p><b>Additional information for Chandeliers</b> </p> <p>The chandeliers are delivered in disassembly status. That means the buyer needs to do the assembling of the arms, crystals of the chandeliers. </p> <p>We recommend using a professional electrician to install the chandelier or lamps on the wall or ceiling to avoid the damages on the electric cables or chandeliers arms. </p> RENMAR Nad Cirochou 2325/25 Snina A RENMAR Nad Cirochou 2325/25 Snina Presovsky kraj SK 06901 renmar@centrum.sk +421(905)968-547 none Y 1612812685 52,46,54 0 a:4:{s:14:"company_fields";a:2:{i:37;s:6:"martin";i:38;s:6:"terpak";}s:15:"admin_firstname";s:6:"martin";s:14:"admin_lastname";s:6:"terpak";s:6:"fields";a:0:{}} N N N 14 1754397943 0 1779277789 0 acct_1IdYgnEOaLZh7SFW S 47619 cdWNfMGCj79f6zrbT7-Ki59d8ykp96fiTKsjNhWnECw 0LbVCuC0kr5hIX3bNhDwJI9Pdx_NO7ry_zIF_TkU--U 2 B2Bonza renmar 2_0