SELECT 
  cscart_companies.company_id, 
  cscart_companies.lang_code, 
  cscart_companies.email, 
  cscart_companies.timestamp, 
  cscart_companies.status, 
  company_descr.i18n_company as company, 
  cscart_companies.tax_number, 
  cscart_company_descriptions.company_description, 
  cscart_companies.stripe_connect_account_id, 
  cscart_companies.paypal_commerce_platform_account_id, 
  absolute_rating.rating AS absolute_vendor_rating, 
  cscart_companies.minimum_order_total, 
  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(
    cscart_companies.company_id, 
    '_', 
    IF (
      cscart_discussion_rating.thread_id, 
      cscart_discussion_rating.thread_id, 
      '0'
    )
  ) AS company_thread_ids, 
  cscart_companies.suspend_date, 
  cscart_companies.last_time_suspended 
FROM 
  cscart_companies 
  LEFT JOIN cscart_company_descriptions as company_descr ON company_descr.company_id = cscart_companies.company_id 
  AND company_descr.lang_code = 'en' 
  LEFT JOIN cscart_company_descriptions ON cscart_company_descriptions.company_id = cscart_companies.company_id 
  AND cscart_company_descriptions.lang_code = 'en' 
  LEFT JOIN cscart_absolute_rating AS absolute_rating ON absolute_rating.object_id = cscart_companies.company_id 
  AND absolute_rating.object_type = 'company' 
  LEFT JOIN cscart_vendor_plan_descriptions ON cscart_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 = cscart_companies.company_id 
  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 = cscart_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 
  1 
  AND cscart_companies.status = 'A' 
  AND cscart_companies.company_id IN (2, 64, 92, 103, 104, 121, 127) 
GROUP BY 
  company_thread_ids 
ORDER BY 
  company_descr.i18n_company asc 
LIMIT 
  0, 30

Query time 0.00007

JSON explain

{
  "query_block": {
    "select_id": 1,
    "filesort": {
      "sort_key": "company_descr.i18n_company",
      "temporary_table": {
        "nested_loop": [
          {
            "table": {
              "table_name": "cscart_companies",
              "access_type": "ALL",
              "possible_keys": ["PRIMARY"],
              "rows": 12,
              "filtered": 58.33333206,
              "attached_condition": "cscart_companies.`status` = 'A' and cscart_companies.company_id in (2,64,92,103,104,121,127)"
            }
          },
          {
            "table": {
              "table_name": "company_descr",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "10",
              "used_key_parts": ["company_id", "lang_code"],
              "ref": ["ebonza_cscart_test.cscart_companies.company_id", "const"],
              "rows": 1,
              "filtered": 100,
              "attached_condition": "trigcond(company_descr.lang_code = 'en')"
            }
          },
          {
            "table": {
              "table_name": "cscart_company_descriptions",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "10",
              "used_key_parts": ["company_id", "lang_code"],
              "ref": ["ebonza_cscart_test.cscart_companies.company_id", "const"],
              "rows": 1,
              "filtered": 100,
              "attached_condition": "trigcond(cscart_company_descriptions.lang_code = 'en')"
            }
          },
          {
            "table": {
              "table_name": "absolute_rating",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "102",
              "used_key_parts": ["object_id", "object_type"],
              "ref": ["ebonza_cscart_test.cscart_companies.company_id", "const"],
              "rows": 1,
              "filtered": 100,
              "attached_condition": "trigcond(absolute_rating.object_type = 'company')"
            }
          },
          {
            "table": {
              "table_name": "cscart_vendor_plan_descriptions",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "10",
              "used_key_parts": ["plan_id", "lang_code"],
              "ref": ["ebonza_cscart_test.cscart_companies.plan_id", "const"],
              "rows": 1,
              "filtered": 100,
              "attached_condition": "trigcond(cscart_vendor_plan_descriptions.lang_code = 'en')"
            }
          },
          {
            "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": [
                "ebonza_cscart_test.cscart_companies.company_id",
                "const",
                "const",
                "const"
              ],
              "rows": 16,
              "filtered": 100,
              "attached_condition": "trigcond(cscart_seo_names.object_id = cscart_companies.company_id and cscart_seo_names.`type` = 'm' and cscart_seo_names.dispatch = '' and cscart_seo_names.lang_code = 'en')"
            }
          },
          {
            "table": {
              "table_name": "cscart_discussion",
              "access_type": "eq_ref",
              "possible_keys": ["object_id"],
              "key": "object_id",
              "key_length": "6",
              "used_key_parts": ["object_id", "object_type"],
              "ref": ["ebonza_cscart_test.cscart_companies.company_id", "const"],
              "rows": 1,
              "filtered": 100,
              "attached_condition": "trigcond(cscart_discussion.object_id = cscart_companies.company_id and 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": "256Kb",
              "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 email timestamp status company tax_number company_description stripe_connect_account_id paypal_commerce_platform_account_id absolute_vendor_rating minimum_order_total plan seo_name seo_path average_rating company_thread_ids suspend_date last_time_suspended
64 en sneakerstown@seznam.cz 1749992053 A B2Bonza Test Vendor <h3>Testovaci vendor ucet </h3> <p><span class="Yjhzub">Lorem ipsum dolor sit amet</span>, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit animit est laborum.</p><p><br /></p><p><img src="https://ebonza.eu/images/companies/64/2.png?1779869752450" alt="2.png?1779869752450" /><br /></p> <p><br /></p> <p><img src="https://ebonza.eu/images/companies/64/ChatGPT%20Image%20Jan%2023%2C%202026%2C%2007_34_51%20PM.png?1779869835028" alt="ChatGPT%20Image%20Jan%2023%2C%202026%2C%2007_34_51%20PM.png?1779869835028" /></p> <div class="video-container"><iframe style="width:500px;height:281px;" src="//www.youtube.com/embed/4jjnUAXIcQY" frameborder="0" allowfullscreen=""></iframe></div> <p><br /></p> acct_1RaGJUQZ1vcS5kzm 113 150 Founding Brands Program martin-terpak 64_0 0 0
2 en renmar@centrum.sk 1612812685 A RENMAR <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> acct_1IdYgnEOaLZh7SFW 22 2 B2Bonza renmar 2_0 1754397943 1779277789
92 en retedi@seznam.cz 1768385582 A RetediCZ B2Bonza retedicz 92_0 0 0
103 en brandtest@seznam.cz 1775812009 A Test Vendor no VAT acct_1TlTGBQi8q2NeOSL Pre-registration test-vendor-no-vat 103_0 0 0
104 en martin@mail.b2bonza.com 1775813518 A TEST VENDOR with VAT CZ29299896 Pre-registration test-vendor-with-vat 104_0 0 0
127 en vendor310@yopmail.com 1786108657 A vendor310 Pre-registration vendor310 127_0 0 0