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 = 139 
  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 = 139

Query time 0.00103

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "2.85"
    },
    "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.88",
            "eval_cost": "0.10",
            "prefix_cost": "0.98",
            "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.73",
            "eval_cost": "0.10",
            "prefix_cost": "1.81",
            "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.23",
            "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.85",
            "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
139 en <p><span style="font-family: inherit; font-size: 16.25px; font-weight: 600; color: rgb(128, 100, 162);">Hello!&nbsp; Welcome to Personalized Country Creations!&nbsp; My name is Trina!&nbsp; I started creating personalized items in 2017 in my studio in beautiful West Virginia.&nbsp; I love to create items with a special meaning to you!&nbsp; Every item I create for you is created with care so the finished item is how you envisioned!&nbsp; I love the messages I get letting me know how much my item meant to someone.&nbsp;</span></p> <p><span style="font-family: inherit; font-size: 16.25px; font-weight: 600; color: rgb(128, 100, 162);">I love to create custom items!&nbsp; Please message me if you have something special you would like created!&nbsp; Follow my Facebook page to see new designs and products!</span><span style="color: inherit; font-family: inherit; font-size: 16.25px; font-weight: 600;">&nbsp;</span></p> <h4><span style="color: rgb(128, 100, 162);">Trina</span></h4> <p>Email:&nbsp;&nbsp;<a href="mailto:trina@country-creations.com">trina@country-creations.com</a></p> <p>&nbsp;<a href="https://www.facebook.com/personalizedcountrycreations/" style="font-weight: 700;">https://www.facebook.com/persosonalizedcountrycreations</a></p> <p><strong><span style="color: rgb(79, 129, 189);">I appreciate your order and look forward to creating something special for you!</span></strong></p> <p><span class="yiv9654668068s1"></span> </p> <p>Each item is created especially for you!&nbsp;&nbsp;The processing time is listed on each item!&nbsp;&nbsp;If you&nbsp;order multiple items with different processing times all items will ship according to the longest processing time.&nbsp;&nbsp;Please contact me if you’d like each item to ship separately so a custom listing can be made for separate shipping cost.&nbsp;&nbsp;</p> <p><span class="yiv9654668068s1"></span> </p> <p><span class="yiv9654668068s1"></span> </p> <p><span class="yiv9654668068s1">If your order includes a photo personalization please provide a crisp, clear photo that is not cropped when uploading the photo.&nbsp;</span></p> <p><span class="yiv9654668068s1"></span> </p> <p><span class="yiv9654668068s1">For personalized items a proof will be sent to you within 72 hours via your email.&nbsp;<span class="yiv9654668068Apple-converted-space">&nbsp;</span>Please promptly respond so your order is not delayed!</span></p> <p><b>Shipping:</b></p> <ul><li>Shipping is via USPS First Class postage.&nbsp;&nbsp;Delivery time is dependent upon current USPS conditions.&nbsp; No delivery date can be guaranteed.</li><li>If the package shows damage when delivered please photograph the damage before opening.&nbsp;&nbsp;Also photograph any damage to the product.&nbsp;&nbsp;&nbsp;Email these photos to info@country-creations.com so a claim can be made with USPS.&nbsp;&nbsp;&nbsp;Please retain any damaged packaging material in the event the USPS requires to see it.&nbsp;&nbsp;</li><li>Customer is responsible for providing a correct address.&nbsp;&nbsp;Items returned due to incorrect address will not be refunded and customer is responsible for the shipping charge to resend.&nbsp;&nbsp;</li><li>Please have packages delivered to a secure location.&nbsp;&nbsp;No refunds or replacements will be issued for items showing delivered.&nbsp;</li></ul> <p><b>Cancellations:</b></p> <ul><li>You may request a cancellation within 24 hours of placing your order for a full refund!&nbsp; Please message me via the goimagine message center or email info@country-creations.com.</li></ul> <p><span class="yiv9654668068s1"><b>Returns:</b></span></p> <p><span class="yiv9654668068s1">Returns are accepted under the following conditions:</span></p> <ul><li>Customer must email info@country-creations.com within 3 days of delivery for a Return Authorization Number.&nbsp;&nbsp;The email must state the reason for a return and include any applicable photos.&nbsp;&nbsp;</li><li>Customer is responsible for return shipping.&nbsp;&nbsp;&nbsp;Once the authorization number is provided the item needs to be returned with 7 days.&nbsp;&nbsp;Please email the tracking number to info@country-creations.com.&nbsp;&nbsp;</li><li>A refund will be processed once the item is received back in the same condition it was sent.&nbsp;&nbsp;</li></ul> <p><span class="yiv9654668068s1"></span></p> <p><span class="yiv9654668068s1"></span></p> <p><strong>Please note:</strong><br></p> <ul><li>&nbsp;Actual colors may vary from colors shown on your device.&nbsp;&nbsp;Devices are backlit so this can affect how colors are shown.&nbsp;</li><li>Each design is hand placed. There may be slight variations in the pattern shown in the item photo.&nbsp;&nbsp;</li></ul> <p><strong>I am happy to answer any questions before or after your order!&nbsp; Please message me via the goimagine message center or email info@country-creations.com</strong></p> {"tmenu_style":"V","default_colors":"N","link_color":"#990000","label_color":"#cc4125","icon_color":"#cc4125","main_btn_color":"#cc0000","branded_text_color":"#a61c00","vbp_1_url":"","vbp_2_url":"","vbp_3_url":"https://personalized-country-creations.aweb.page/p/323af950-d8b7-49f1-9fc0-2ca9ee9b8410","vba_1_url":"","vba_2_url":"https://country-creations.goimagine.com/all-shop-items/","vba_3_url":"https://www.facebook.com/personalizedcountrycreations"} Personalized Country Creations 261 Fallen Timber Dr Parkersburg A Personalized Country Creations 261 Fallen Timber Dr Parkersburg WV US 26105 info@country-creations.com none Y 1584741821 26 a:4:{s:14:"company_fields";a:2:{i:37;s:5:"Trina";i:38;s:4:"Earl";}s:15:"admin_firstname";s:5:"Trina";s:14:"admin_lastname";s:4:"Earl";s:6:"fields";a:0:{}} 3 acct_1GM4E5I1nmYlMi5x 805806393697998 292634,292628,285031,285496,285550,285559,300410,300383,289841,289881,289861,281182,280489,279675,280165,279111,88169,227549,216387,74674,232825 UA-177702409-1 XXT83Z6HN848G A personalized item touches the heart! https://www.facebook.com/personalizedcountrycreations https://www.instagram.com/personalizedcountrycreations/ https://www.pinterest.com/personalizedcountrycreations/_created/ <p><br></p> <p><br></p> UA-248879137-1 805806393697998 testing.cpom, A N 1722535177 0 0 0 0 S Professional Plan country-creations 5.0000 139_751