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

Query time 0.00099

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "2.78"
    },
    "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.84",
            "eval_cost": "0.10",
            "prefix_cost": "0.94",
            "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.74",
            "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.17",
            "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.78",
            "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
653 en <p><span class="mt-xs-1" data-inplace-editable-text="story" data-endpoint="AboutPost" data-key="story" data-placeholder="How did you get started? What inspires you? We know each seller’s story is unique&mdash;tell yours here."></span></p> <p>MAKING YOUR FAVORITE THINGS IS OUR FAVORITE THING</p> <p>For designer and founder, Kimberly Cap, creating gifts that speak to you is the ultimate goal &mdash; even more so when that gift is for you. From the softest graphic tees and personalized towels to special tote bags, pillows and sassy gifts, this is where personality shines and hearts become full. <br></p> <p>Capable by Design is a brand built around thoughtfulness. Vibrant and spirited. Inclusive and happy. This is where bad days don’t exist, because Kimberly &mdash; wife, mom, gramma and dog momma &mdash; is focused on delivering what you’ll love; the custom pieces you wish for; and the gifts you need to spoil those you love. Because when you shop here, every day is made. <br></p> <p><span class="mt-xs-1" data-inplace-editable-text="story" data-endpoint="AboutPost" data-key="story" data-placeholder="How did you get started? What inspires you? We know each seller’s story is unique&mdash;tell yours here."><em>choose to stand out </em></span><em></em><br></p> <p></p> <p></p> <p><b><u>SHIPPING:</u></b> </p> <p>Processing time is currently 1-5 business days, please allow for additional processing times during holidays. Processing time is the time I need to prepare an order for shipping and doesn't include shipping. </p> <p>Estimated shipping times United States: 5-7 business days, I'll do my best to meet these shipping estimates, but cannot guarantee them. </p> <p><b><u>RETURNS AND EXCHANGES:</u></b> </p> <p>Contact me within 5 days of delivery. Ship items back within 14 days of delivery </p> <p><b><u>I DON’T ACCEPT CANCELLATIONS: </u></b> </p> <p>But please contact me if you have any problems with your order. </p> <p><b><u>THE FOLLOWING ITEMS CANNOT BE RETURNED OR EXCHANGED:</u></b> </p> <p>Because of the nature of these items, unless they arrive damaged or defective, I cannot accept returns for: </p> <ul><li>Custom or personalized orders </li></ul> <p>Conditions of return: Buyers are responsible for return shipping costs. If the item is not returned in its original condition, the buyer is responsible for any loss in value. <br></p> <p> </p> <p><br></p> <p></p> <p><b>FREQUENTLY ASKED QUESTIONS:</b> </p> <p><b>Returns and Exchange Details</b> </p> <p>I offer refunds or exchanges for defective products. I do not offer refunds or exchanges on any custom-made personalized products unless it is defective. Please message me if you have a question regarding your order and I will be happy to look over your situation! </p> <p><b>What if I am shipping multiple gifts?</b> </p> <p>If you are purchasing more than one gift to be shipped to different addresses, each item must be its own separate order. Thank you. </p> <p><b>Care instructions</b> </p> <p>Care instructions are listed in each product description, if you have any questions, please don't hesitate to message me. </p> <p>&nbsp; </p> <p></p> <p><strong><br></strong></p> <p><br></p> {"tmenu_style":"H","default_colors":"N","link_color":"#007d89","label_color":"#00a0af","icon_color":"#00a0af","main_btn_color":"#6dd1d6","branded_text_color":"#00a0af","vbp_1_url":"","vbp_2_url":"https:\/\/goimagine.com\/holidays\/christmas\/christmas-ornaments-en\/","vbp_3_url":"https:\/\/goimagine.com\/fun-games\/games-and-puzzles\/road-trip-fun-bundle\/","vba_1_url":"","vba_2_url":"","vba_3_url":""} Capable By Design 12040 W 81st Ct Saint John A Capable By Design 12040 W 81st Ct Saint John IN US 46373 kimberly@capablebydesign.com none Y 1590707403 0 a:4:{s:14:"company_fields";a:2:{i:37;s:8:"Kimberly";i:38;s:3:"Cap";}s:15:"admin_firstname";s:8:"Kimberly";s:14:"admin_lastname";s:3:"Cap";s:6:"fields";a:0:{}} 4 acct_1Go7NRHarPEo6W8s 382665885592973 87519,203739,87801,134126,44929,192420,181100,181099,197336,193274,187111,197271,203852,203841,23912,176023,176223,84653,131163,85897,137950,80607,78742,153269,82843,153271,176022,181102,181101,83865,79303,79584,198999,188206,199005,112510 UA-114085873-3 RXPN4Z3RBT6H4 choose to stand out https://www.facebook.com/CapableByDesign https://www.instagram.com/CapableByDesign https://www.pinterest.com/CapableByDesign <p><span class="d2edcug0 hpfvmrgz qv66sw1b c1et5uql lr9zc1uh a8c37x1j keod5gw0 nxhoafnm aigsh9s9 d3f4x2em fe6kdd0r mau55g9w c8b282yb iv3no6db jq4qci2q a3bd9o3v b1v8xokw oo9gr5id hzawbc8m" dir="auto"></span></p> <p>Thank you for stopping at our shop!&nbsp; Here you will find whimsical apparel, accessories, and custom gifts!&nbsp; We have the softest lightweight graphic tees and personalized towels to special tote bags, pillows, and sassy gifts, for all the special people in your life. <br></p> <p><br></p> <p><br><br></p> <p><br> </p> <p><span class="d2edcug0 hpfvmrgz qv66sw1b c1et5uql lr9zc1uh a8c37x1j keod5gw0 nxhoafnm aigsh9s9 d3f4x2em fe6kdd0r mau55g9w c8b282yb iv3no6db jq4qci2q a3bd9o3v b1v8xokw oo9gr5id hzawbc8m" dir="auto"></span> <br></p> <p><span class="display-block"><br></span><br></p> oauth.3yB7xk-O9dkIsoq3CjLJSDKUx8QjcexEIPykaCi6.35cdKFurfV_BrFLHOgcjRFGawem63eBbyx3cbZECFcU UA-114085873-3 382665885592973 A {"items_per_file":"2500","time_from":"","time_to":""} N 0 0 0 0 0 S All-Star Plan capablebydesign 5.0000 653_9763