SELECT 
  tmall_companies.company_id, 
  tmall_companies.lang_code, 
  tmall_companies.email, 
  tmall_companies.timestamp, 
  tmall_companies.status, 
  tmall_companies.company, 
  tmall_companies.tax_number, 
  absolute_rating.rating AS absolute_vendor_rating, 
  tmall_vendor_plan_descriptions.plan, 
  AVG(
    tmall_discussion_rating.rating_value
  ) AS average_rating, 
  CONCAT(
    tmall_companies.company_id, 
    '_', 
    IF (
      tmall_discussion_rating.thread_id, 
      tmall_discussion_rating.thread_id, 
      '0'
    )
  ) AS company_thread_ids, 
  vendor_locations.lat, 
  vendor_locations.lng 
FROM 
  tmall_companies 
  LEFT JOIN tmall_absolute_rating AS absolute_rating ON absolute_rating.object_id = tmall_companies.company_id 
  AND absolute_rating.object_type = 'company' 
  LEFT JOIN tmall_vendor_plan_descriptions ON tmall_companies.plan_id = tmall_vendor_plan_descriptions.plan_id 
  AND tmall_vendor_plan_descriptions.lang_code = 'en' 
  LEFT JOIN tmall_discussion ON tmall_discussion.object_id = tmall_companies.company_id 
  AND tmall_discussion.object_type = 'M' 
  LEFT JOIN tmall_discussion_posts ON tmall_discussion_posts.thread_id = tmall_discussion.thread_id 
  AND tmall_discussion_posts.status = 'A' 
  LEFT JOIN tmall_discussion_rating ON tmall_discussion.thread_id = tmall_discussion_rating.thread_id 
  AND tmall_discussion_rating.post_id = tmall_discussion_posts.post_id 
  LEFT JOIN tmall_vendor_locations AS vendor_locations ON vendor_locations.company_id = tmall_companies.company_id 
WHERE 
  1 
  AND tmall_companies.status = 'A' 
GROUP BY 
  company_thread_ids 
ORDER BY 
  tmall_companies.company asc

Query time 0.00910

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.057738018,
    "filesort": {
      "sort_key": "tmall_companies.company",
      "temporary_table": {
        "nested_loop": [
          {
            "table": {
              "table_name": "absolute_rating",
              "access_type": "system",
              "possible_keys": ["PRIMARY"],
              "rows": 0,
              "filtered": 0,
              "const_row_not_found": true
            }
          },
          {
            "table": {
              "table_name": "tmall_companies",
              "access_type": "ALL",
              "loops": 1,
              "rows": 2,
              "cost": 0.01034841,
              "filtered": 100,
              "attached_condition": "tmall_companies.`status` = 'A'"
            }
          },
          {
            "table": {
              "table_name": "tmall_vendor_plan_descriptions",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "10",
              "used_key_parts": ["plan_id", "lang_code"],
              "ref": ["tmall.tmall_companies.plan_id", "const"],
              "loops": 2,
              "rows": 1,
              "cost": 0.003662852,
              "filtered": 100,
              "attached_condition": "trigcond(tmall_vendor_plan_descriptions.lang_code = 'en')"
            }
          },
          {
            "table": {
              "table_name": "tmall_discussion",
              "access_type": "eq_ref",
              "possible_keys": ["object_id"],
              "key": "object_id",
              "key_length": "6",
              "used_key_parts": ["object_id", "object_type"],
              "ref": ["tmall.tmall_companies.company_id", "const"],
              "loops": 2,
              "rows": 1,
              "cost": 0.003662852,
              "filtered": 100,
              "attached_condition": "trigcond(tmall_discussion.object_id = tmall_companies.company_id and tmall_discussion.object_type = 'M')"
            }
          },
          {
            "table": {
              "table_name": "tmall_discussion_posts",
              "access_type": "ref",
              "possible_keys": ["thread_id", "thread_id_2"],
              "key": "thread_id",
              "key_length": "3",
              "used_key_parts": ["thread_id"],
              "ref": ["tmall.tmall_discussion.thread_id"],
              "loops": 2,
              "rows": 6,
              "cost": 0.016182712,
              "filtered": 100,
              "attached_condition": "trigcond(tmall_discussion_posts.`status` = 'A' and trigcond(tmall_discussion.thread_id is not null))"
            }
          },
          {
            "table": {
              "table_name": "tmall_discussion_rating",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY", "thread_id"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["post_id"],
              "ref": ["tmall.tmall_discussion_posts.post_id"],
              "loops": 12,
              "rows": 1,
              "cost": 0.020953112,
              "filtered": 100,
              "attached_condition": "trigcond(tmall_discussion_rating.thread_id = tmall_discussion.thread_id and trigcond(tmall_discussion_posts.post_id is not null))"
            }
          },
          {
            "table": {
              "table_name": "vendor_locations",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "4",
              "used_key_parts": ["company_id"],
              "ref": ["tmall.tmall_companies.company_id"],
              "loops": 12,
              "rows": 1,
              "cost": 0.00292808,
              "filtered": 100,
              "attached_condition": "trigcond(vendor_locations.company_id = tmall_companies.company_id)"
            }
          }
        ]
      }
    }
  }
}

Result

company_id lang_code email timestamp status company tax_number absolute_vendor_rating plan average_rating company_thread_ids lat lng
2 en acme_corp@example.com 1269610461 A ACME Corp Bronze 2_0
1 en cs-cart@example.com 1269610461 A CS-Cart Gold 1_0