SELECT 
  company_descriptions.*, 
  companies.*, 
  vendor_plan_descriptions.plan, 
  seo_names.name as seo_name, 
  seo_names.path as seo_path, 
  vendor_ga_tracking_code, 
  vendor_fb_tracking_code, 
  AVG(discussion_rating.rating_value) AS average_rating, 
  CONCAT(
    companies.company_id, 
    '_', 
    IF (
      discussion_rating.thread_id, discussion_rating.thread_id, 
      '0'
    )
  ) AS company_thread_ids 
FROM 
  companies AS companies 
  LEFT JOIN company_descriptions AS company_descriptions ON company_descriptions.company_id = companies.company_id 
  AND company_descriptions.lang_code = 'en' 
  LEFT JOIN vendor_plan_descriptions ON companies.plan_id = vendor_plan_descriptions.plan_id 
  AND vendor_plan_descriptions.lang_code = 'en' 
  LEFT JOIN seo_names ON seo_names.object_id = 6358 
  AND seo_names.type = 'm' 
  AND seo_names.dispatch = '' 
  AND seo_names.lang_code = 'en' 
  LEFT JOIN discussion as discussionA ON discussionA.object_id = companies.company_id 
  AND discussionA.object_type = 'M' 
  LEFT JOIN discussion_posts ON discussion_posts.thread_id = discussionA.thread_id 
  AND discussion_posts.status = 'A' 
  LEFT JOIN discussion_rating ON discussionA.thread_id = discussion_rating.thread_id 
  AND discussion_rating.post_id = discussion_posts.post_id 
WHERE 
  companies.company_id = 6358

Query time 0.00112

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "2.77"
    },
    "nested_loop": [
      {
        "table": {
          "table_name": "companies",
          "access_type": "const",
          "possible_keys": [
            "PRIMARY"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "company_id"
          ],
          "key_length": "4",
          "ref": [
            "const"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.00",
            "eval_cost": "0.10",
            "prefix_cost": "0.00",
            "data_read_per_join": "14K"
          },
          "used_columns": [
            "company_id",
            "status",
            "company",
            "lang_code",
            "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",
            "plan_id",
            "stripe_connect_account_id",
            "identifier_facebook_pixel",
            "featured_products",
            "sd_ga_tracking_code",
            "paypal_commerce_platform_account_id",
            "tagline",
            "url_facebook",
            "url_instagram",
            "url_twitter",
            "url_pinterest",
            "announcement",
            "shippo_api_token",
            "shippo_carrier",
            "shippo_service_type",
            "vendor_ga_tracking_code",
            "vendor_fb_tracking_code",
            "custom_domain",
            "custom_domain_status",
            "taxjar_key",
            "taxjar_export_statuses",
            "taxjar_export_csv_data",
            "ag_hide_city",
            "updated_timestamp",
            "suspend_date",
            "grace_period_start",
            "last_time_suspended",
            "last_debt_notification_time",
            "tax_number",
            "stripe_connect_account_type",
            "registered_from_storefront_id"
          ]
        }
      },
      {
        "table": {
          "table_name": "company_descriptions",
          "access_type": "const",
          "possible_keys": [
            "PRIMARY"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "company_id",
            "lang_code"
          ],
          "key_length": "10",
          "ref": [
            "const",
            "const"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.00",
            "eval_cost": "0.10",
            "prefix_cost": "0.00",
            "data_read_per_join": "1K"
          },
          "used_columns": [
            "company_id",
            "lang_code",
            "company_description",
            "terms",
            "subdomain_colors",
            "i18n_company",
            "i18n_address",
            "i18n_city"
          ]
        }
      },
      {
        "table": {
          "table_name": "vendor_plan_descriptions",
          "access_type": "const",
          "possible_keys": [
            "PRIMARY"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "plan_id",
            "lang_code"
          ],
          "key_length": "10",
          "ref": [
            "const",
            "const"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.00",
            "eval_cost": "0.10",
            "prefix_cost": "0.00",
            "data_read_per_join": "1K"
          },
          "used_columns": [
            "plan_id",
            "lang_code",
            "plan"
          ]
        }
      },
      {
        "table": {
          "table_name": "seo_names",
          "access_type": "ref",
          "possible_keys": [
            "PRIMARY",
            "dispatch"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "object_id",
            "type",
            "dispatch",
            "lang_code"
          ],
          "key_length": "206",
          "ref": [
            "const",
            "const",
            "const",
            "const"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.83",
            "eval_cost": "0.10",
            "prefix_cost": "0.93",
            "data_read_per_join": "1K"
          },
          "used_columns": [
            "name",
            "object_id",
            "type",
            "dispatch",
            "path",
            "lang_code"
          ]
        }
      },
      {
        "table": {
          "table_name": "discussionA",
          "access_type": "const",
          "possible_keys": [
            "object_id"
          ],
          "key": "object_id",
          "used_key_parts": [
            "object_id",
            "object_type"
          ],
          "key_length": "6",
          "ref": [
            "const",
            "const"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.70",
            "eval_cost": "0.10",
            "prefix_cost": "1.73",
            "data_read_per_join": "24"
          },
          "used_columns": [
            "thread_id",
            "object_id",
            "object_type"
          ]
        }
      },
      {
        "table": {
          "table_name": "discussion_posts",
          "access_type": "ref",
          "possible_keys": [
            "thread_id",
            "thread_id_2"
          ],
          "key": "thread_id_2",
          "used_key_parts": [
            "thread_id",
            "status"
          ],
          "key_length": "6",
          "ref": [
            "goimagine.discussionA.thread_id",
            "const"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "using_index": true,
          "cost_info": {
            "read_cost": "0.25",
            "eval_cost": "0.18",
            "prefix_cost": "2.16",
            "data_read_per_join": "787"
          },
          "used_columns": [
            "post_id",
            "thread_id",
            "status"
          ]
        }
      },
      {
        "table": {
          "table_name": "discussion_rating",
          "access_type": "eq_ref",
          "possible_keys": [
            "PRIMARY",
            "thread_id"
          ],
          "key": "PRIMARY",
          "used_key_parts": [
            "post_id"
          ],
          "key_length": "3",
          "ref": [
            "goimagine.discussion_posts.post_id"
          ],
          "rows_examined_per_scan": 1,
          "rows_produced_per_join": 1,
          "filtered": "100.00",
          "cost_info": {
            "read_cost": "0.44",
            "eval_cost": "0.18",
            "prefix_cost": "2.77",
            "data_read_per_join": "28"
          },
          "used_columns": [
            "rating_value",
            "post_id",
            "thread_id"
          ],
          "attached_condition": "<if>(is_not_null_compl(discussion_rating), (`goimagine`.`discussion_rating`.`thread_id` = `goimagine`.`discussionA`.`thread_id`), true)"
        }
      }
    ]
  }
}

Result

company_id lang_code company_description terms subdomain_colors 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 plan_id stripe_connect_account_id identifier_facebook_pixel featured_products sd_ga_tracking_code paypal_commerce_platform_account_id tagline url_facebook url_instagram url_twitter url_pinterest announcement shippo_api_token shippo_carrier shippo_service_type vendor_ga_tracking_code vendor_fb_tracking_code custom_domain custom_domain_status taxjar_key taxjar_export_statuses taxjar_export_csv_data ag_hide_city updated_timestamp suspend_date grace_period_start last_time_suspended last_debt_notification_time tax_number stripe_connect_account_type registered_from_storefront_id plan seo_name seo_path average_rating company_thread_ids
6358 en <p>Hi, and welcome. I have been making all kinds of crafts for all of my adult life. I love making primitives and country decor. I have a small room that I work in, and cannot keep a large amount of product in stock because my space is very limited. Most small Items I can get done in a few days. Made to Order items take longer.&nbsp; If you have any questions, don't hesitate to ask.&nbsp; Thank you for stopping by.</p> <p><span style="color: rgb(255, 255, 0);"></span>Payments accepted are through Stripe or Paypal.<span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(255, 255, 0);"></span><span style="background-color: rgb(255, 255, 0);"></span></p> <p><span style="background-color: rgb(255, 255, 0);">FINISHED IN STOCK ITEMS </span>will ship in&nbsp; 3-5 days after ordering.&nbsp; Once shipped allow 3-7 days to receive your order, depending on shipping level.&nbsp;<span class="Apple-converted-space">&nbsp;</span></p> <p><span style="color: rgb(255, 255, 0);"></span>&nbsp;<span style="background-color: rgb(255, 255, 0);">MADE TO ORDER&nbsp; ITEMS&nbsp;</span> will take approximately 7-10 days to complete. Once shipped allo<span style="color: rgb(0, 0, 0);"></span>w 3-7 days to receive your order, depending on shipping level.&nbsp;<span class="Apple-converted-space">&nbsp;&nbsp;</span></p> <p>Because of the nature of primitives, we do not offer returns or refunds. Each piece is unique and has their own characteristics. No two pieces ever turn out the same.&nbsp;</p> <p>Items are not toys. Some may have wires, glass glitter, beads for eyes, etc. Do not let children play with them.</p> <p><br></p> <p>If you have any questions about an item please message me before purchasing.&nbsp;<br></p> {"tmenu_style":"V","default_colors":"N","link_color":"#666666","label_color":"#bf9000","icon_color":"#666666","main_btn_color":"#666666","branded_text_color":"#f1c232","vbp_1_url":"","vbp_2_url":"","vbp_3_url":"","vba_1_url":"","vba_2_url":"","vba_3_url":""} Crusty Old Crows 6112 Maplewood Road mentor on the lake A Crusty Old Crows 6112 Maplewood Road mentor on the lake OH US 44060 crustyoldcrows@gmail.com +14403827999 none Y 1649903325 0 4 acct_1KpZAsLA6BffPXtx 207407,272008,303195 9VPM4W53B6UHW Primitives and Country Decor www.facebook.com/crustyoldcrows www.pinterest.com/crustyoldcrows <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: rgb(149, 55, 52);"> &nbsp; &nbsp; &nbsp; &nbsp; <span></span></span><span style="color: rgb(149, 55, 52);">&nbsp;</span></p> <p></p> <p>Welcome to Crusty Old Crows. Primitive home decor is what you will find here.&nbsp; It takes you back to simpler times and gives your home a warm welcoming feeling. Primitives caught my eye many years ago. I love the fact that they do not have that store look. Everything comes out different each time they are made. I personally do not like all of the bright decorations, especially for Halloween.&nbsp; I love making primitives with that old grungy effect even though it is sometimes a messy process. I sometimes use patterns from some very creative artists, and sometimes I happen to come up with an idea on my own.&nbsp; Crafting of all kinds is a passion of mine. Primitives are my go-to craft now, but I have made quilts, knitted, crocheted, rug hooking, Punch needle and more. Too many ideas, and so little time to do them all.&nbsp;</p> <p>&nbsp;Handmade is always a great gift. Support the artists here on Goimagine, we put our heart and soul into everything we make. So many special items for the special people in your life.&nbsp;</p> <p>Thank you for stopping by and seeing what I have to offer.&nbsp;&nbsp;</p> <p>If you have any questions about my items please message me.&nbsp;</p> oauth.AntwgwhrZcTXIsWB17wqprfZ59RBy62Tf-f6RPFu._Bu40pVtU2jALTCjlhRfIRtRSCGiaaKx4u6V6j5JRBM UA-257780928-1 A N 0 0 0 0 0 S All-Star Plan crustyoldcrows 6358_0