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

Query time 0.00250

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "2.87"
    },
    "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.75",
            "eval_cost": "0.10",
            "prefix_cost": "1.83",
            "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.26",
            "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.87",
            "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
206 en <p><strong><span style="color: rgb(49, 133, 155);"><img src="https://goimagine.com/images/companies/206/etsy%20portrait.jpg?1585847022876" style="width: 100px; height: 100px; margin: 0px 0px 10px 10px; float: right;" width="100" height="100"></span></strong></p> <p><strong><span style="color: rgb(49, 133, 155);">Hi! I'm Terri and welcome to Sand & Sea Custom Signs!</span></strong> The beach has always been my happy place and where I relax, find peace and get my inspiration. I grew up spending my summers on Long Beach Island, NJ, and moved to FL in 1990. As a graphic designer for over 37 years, I love creating anything from print pieces to wood signs! If you can say it, think it, feel it, memorize it, if it makes you laugh, smile or even shed a tear... I can make you a sign with it! Please find and follow me on <a href="http://www.facebook.com/sandandseacustomsigns" target="_blank">Facebook</a>, <a href="http://www.instagram.com/sandandseacustomsigns" target="_blank">Instagram</a> and <a href="http://www.pinterest.com/sandandseacustomsigns" target="_blank">Pinterest</a> and keep up with all of my new designs, I&nbsp;would love to connect!</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.">My last full time job was working in a Christian non-profit’s creative dept. Through this organization, I was able to take a trips to the countries we worked in, one of them being Nicaragua. That experience set me on a new path and a new journey that lead to the adoption of my daughter. Since that journey began, I started a freelance business so that I could work from home.</span></p> <p>Creating signs became a fun hobby, then it became a great gift idea for friends and family and now I’m trying to grow this hobby into something bigger! I’m excited to be here on Goimagine sharing my work with all of you!</p> <p>Every sign is made of wood, cut to size, sanded, stained and/or painted and uniquely designed for you. Thank you for being a part of this new journey!</p> <p><br></p> <div class="video-container"><iframe style="width: 500px; height: 281px;" src="//www.youtube.com/embed/oN18z32XA7w" allowfullscreen="" frameborder="0"></iframe></div> <p><br></p> <p><br></p> <h4><span style="caret-color: rgb(36, 64, 97); color: rgb(49, 133, 155);">Sand Sand Sea Custom Signs<br></span></h4> <p><strong><span style="color: rgb(227, 108, 9);">THE PROCESS</span></strong><br>All signs are custom made to order and every sign is unique. We hand pick natural wood and every piece is cut, sanded, painted and/or stained and has a protective coating. *Please advise if a sign will be hung outside as it will need a different coating.&nbsp;</p> <p>All lettering is hand painted and there will be visible brush strokes. No two signs are the same so there may be some slight variations in shade, tone, dings, cracks, knots, character, slight bows and slight warps. Signs are lightly distressed and sanded around the edges. Signs that have real shells and starfish will vary from the original image.<br></p> <p><strong><span style="color: rgb(227, 108, 9);">CUSTOM SIGNS:</span>&nbsp;</strong>If you don't see a quote, verse or color that you like, please reach out and contact us! We would love to make you something unique to your liking.</p> <p><strong><span style="color: rgb(227, 108, 9);">S</span></strong><strong><span style="color: rgb(227, 108, 9);">HIPPING:</span>&nbsp;</strong>Please allow approximately 1-2 weeks for your item to ship as we make each item by hand as they are ordered. If you are purchasing multiple items the production time will be based on the item with the longest production time.</p> <p><strong><span style="color: rgb(227, 108, 9);">RETURNS AND CANCELLATIONS:</span>&nbsp;</strong>No returns or exchanges. I will only accept cancellations within 10 hours after order was placed. But please contact me if you have any problems with your order.</p> <p>**Any items in this photo are for display and staging purpose only and are not included or for sale.</p> <h4><span style="color: rgb(49, 133, 155);">Digital Downloads</span></h4> <p><strong><span style="color: rgb(227, 108, 9);">FOR DIGITAL DOWNLOADS ONLY</span></strong>.&nbsp;*NO physical print, item or frame is shipped*&nbsp;These files need to be downloaded to a computer.&nbsp;*All sales are final on Digital Downloads*</p> <p><strong><span style="color: rgb(227, 108, 9);">COLORS:</span> </strong>Colors can look slightly different when printed compared to what you see on your screen due to different computer monitor settings. Colors also depend on the quality of your home printer inks and the paper used. For best results, I recommend using white high quality card stock or matte finish photo paper.</p> <p><strong><span style="color: rgb(227, 108, 9);">T</span></strong><span style="color: rgb(227, 108, 9);"><strong>ERMS OF USE:</strong></span> The designs sold at Sand and Sea Custom Signs are for <strong>*PERSONAL USE ONLY*</strong> You can print as many times as you wish for your home, office or to give as a gift. The designs can NOT be used for any commercial purpose, resold or shared.</p> <p><br></p> {"tmenu_style":"V","default_colors":"N","link_color":"#007d89","label_color":"#007377","icon_color":"#007377","main_btn_color":"#6dd1d6","branded_text_color":"#007377","vbp_1_url":"","vbp_2_url":"","vbp_3_url":"","vba_1_url":"https:\/\/sandandseacustomsigns.com\/beachy-coastal\/","vba_2_url":"https:\/\/sandandseacustomsigns.com\/personalized-graduation-gift-behind-you-all-your-memories-printable-download\/","vba_3_url":"https:\/\/sandandseacustomsigns.com\/hand-made-signs\/"} Sand & Sea Custom Signs 6027 Terra Rosa Circle Boynton Beach A Sand & Sea Custom Signs 6027 Terra Rosa Circle Boynton Beach FL US 33472 sandandseasigns@gmail.com none Y 1585601853 0 a:4:{s:14:"company_fields";a:2:{i:37;s:5:"Terri";i:38;s:8:"Herzfeld";}s:15:"admin_firstname";s:5:"Terri";s:14:"admin_lastname";s:8:"Herzfeld";s:6:"fields";a:0:{}} 3 acct_1GSn8NKDZYiwB1pm 671994797093579 16858,73067,201492,15753,209595,209598 UA-177232249-1 6YGLAEG7AL2QA High Quality Handmade Wood Signs & Digital Downloads www.facebook.com/sandandseacustomsigns www.Instagram.com/sandandseacustomsigns www.pinterest.com/sandandseacustomsigns <p><strong><span style="color: rgb(149, 55, 52);"><span style="color: rgb(75, 172, 198);">Find that perfect gift or decor. <span style="color: rgb(247, 150, 70);">A sign for every season and occasion!</span></span><br></span></strong></p> UA-177232249-1 671994797093579 sandandseacustomsigns.com A {"items_per_file":"2500","time_from":"","time_to":""} N 0 0 0 0 0 S Professional Plan sandandseacustomsigns 5.0000 206_393