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.paypal_commerce_platform_account_id, 
  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_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' 
GROUP BY 
  company_thread_ids 
ORDER BY 
  company_descr.i18n_company asc 
LIMIT 
  0, 10

Query time 0.00155

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.11488676,
    "filesort": {
      "sort_key": "company_descr.i18n_company",
      "temporary_table": {
        "nested_loop": [
          {
            "table": {
              "table_name": "cscart_companies",
              "access_type": "ALL",
              "loops": 1,
              "rows": 14,
              "cost": 0.0131368,
              "filtered": 100,
              "attached_condition": "cscart_companies.`status` = 'A'"
            }
          },
          {
            "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": ["u508912950_dev_2025.cscart_companies.company_id", "const"],
              "loops": 14,
              "rows": 1,
              "cost": 0.01334136,
              "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": ["u508912950_dev_2025.cscart_companies.company_id", "const"],
              "loops": 14,
              "rows": 1,
              "cost": 0.01334136,
              "filtered": 100,
              "attached_condition": "trigcond(cscart_company_descriptions.lang_code = 'en')"
            }
          },
          {
            "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": ["u508912950_dev_2025.cscart_companies.plan_id", "const"],
              "loops": 14,
              "rows": 1,
              "cost": 0.01334136,
              "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": [
                "u508912950_dev_2025.cscart_companies.company_id",
                "const",
                "const",
                "const"
              ],
              "loops": 14,
              "rows": 1,
              "cost": 0.02005758,
              "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": ["u508912950_dev_2025.cscart_companies.company_id", "const"],
              "loops": 14,
              "rows": 1,
              "cost": 0.01388007,
              "filtered": 100,
              "attached_condition": "trigcond(cscart_discussion.object_id = cscart_companies.company_id and cscart_discussion.object_type = 'M')",
              "using_index": true
            }
          },
          {
            "table": {
              "table_name": "cscart_discussion_posts",
              "access_type": "ref",
              "possible_keys": ["thread_id", "thread_id_2"],
              "key": "thread_id_2",
              "key_length": "6",
              "used_key_parts": ["thread_id", "status"],
              "ref": ["u508912950_dev_2025.cscart_discussion.thread_id", "const"],
              "loops": 14,
              "rows": 1,
              "cost": 0.01444687,
              "filtered": 100,
              "attached_condition": "trigcond(cscart_discussion_posts.`status` = 'A' and trigcond(cscart_discussion.thread_id is not null))",
              "using_index": true
            }
          },
          {
            "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": ["u508912950_dev_2025.cscart_discussion_posts.post_id"],
              "loops": 14,
              "rows": 1,
              "cost": 0.01334136,
              "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 paypal_commerce_platform_account_id plan seo_name seo_path average_rating company_thread_ids suspend_date last_time_suspended
942 en test36oilsmalta@gmail.com 1739711497 A 36Oils <p>36Oils are local artisans specialising in natural body care. All products are blended in Malta using pure, high-quality plant and essential oils, along with other natural extracts. Rooted in a passion for wellness, 36Oils crafts each formula with care, ensuring every product is rich in nutrients and free from harsh chemicals. With a commitment to purity and sustainability, their handcrafted range nourishes the skin while embracing the healing power of nature</p> Free 36oils 942_0 0 0
945 en teststefan@adencosmetics.mt 1739902627 A Aden Cosmetics Malta <span>ADEN Cosmetics has been dedicated to delivering professional-quality makeup at an affordable price. Our mission is to empower your beauty journey with products that are not only reliable and easy to apply but also infused with elegance and practical design. What truly sets us apart is our commitment to innovation, quality, and our vibrant community of trendsetters.</span> Free aden-cosmetics-malta 945_0 0 0
949 en karensha75@gmail.com 1742297960 A BP Beauty <p>At <strong>BP Beauty</strong>, we offer a curated collection of beautifully crafted bags and accessories.</p> <p>Each piece is handpicked for its quality and style, bringing you timeless designs that effortlessly elevate your look.</p> <p>From woven straw bags to unique fabric details, we’re here to offer accessories that blend function with fashion, all at great value.</p> Free bp-beauty 949_0 0 0
969 en pratikvendor@teams.surf.mt 1776705556 A dsdsd Free dsdsd 969_0 0 0
927 en agius.joseph22@gmail.com 1737052261 A Jarts 30586315 <p><span>Combining the natural beauty of wood with intricate Maltese designs, the store offers a range of unique products that celebrate the island's rich cultural heritage. From elegantly carved wooden decor to custom art pieces, every creation tells a story of craftsmanship and tradition.</span></p> <p> </p> <p> </p> Free jarts 927_0 0 0
943 en gloriahan2990@gmail.com 1739874832 A Leather Trove <p>Hand-stitched vegetable tanned leather crafts.</p> <p>Custom-made with precision, honoring tradition and artistry.</p> <p>Made in malta.</p> Free leather-trove 943_0 0 0
947 en harkinsclark@gmail.com 1741350566 A Pine Furniture Direct Crafted for timeless style and durability, our brand specializes in premium solid pine furniture. From sideboards to wardrobes, each piece is built to last with natural charm and expert craftsmanship—perfect for every home. Free pine-furniture-direct 947_0 0 0
779 en ranjith.design07@gmail.com 1735041020 A Surf Shop MT1001 THis is good WYYVL2BEZ6YTA Free surf-brand 779_0 1770010215 1770056517
965 en fahadaligalgotia@gmail.com 1765642243 A Test Fahad Free test-fahad 965_0 0 0
926 en Unknowntapestry@gmail.com 1736162138 A Unknown Tapestry MT26734023 Free unknown-tapestry 926_0 0 0