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

Query time 0.00106

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "2.69"
    },
    "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.80",
            "eval_cost": "0.10",
            "prefix_cost": "0.90",
            "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.64",
            "eval_cost": "0.10",
            "prefix_cost": "1.65",
            "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.07",
            "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.69",
            "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
4401 en <p>Hello there and welcome!&nbsp; My name is Sara and I love creating.&nbsp; I started up about 3 years ago with a laser-cutter and a Cricut Maker, all to help add in some additional income to help support our family.</p> <p>I love creating signs, especially those that are made for encouragement.&nbsp; You'll also see a lot of Christmas Ornaments because I&nbsp;love the holidays.</p> <p>We're not your typical family.&nbsp; It's me, my husband, our two kids, and two dogs.&nbsp; AJ, my son, is an amazing kid who acts like a 40-year-old man.&nbsp; My daughter, Riley, is a warrior.&nbsp; She's my reason.&nbsp; My reason for the need for extra income, my reason I get up in the morning, my reason to fight for those who can't.</p> <p>Riley is an amazing human, a surviving twin, a stroke survivor, and a 2-time brain surgery survivor.&nbsp; She has hydrocephalus, epilepsy, and cerebral palsy, and is globally developmentally delayed.&nbsp; Riley is wheelchair-bound and lacks head and limb control, she's non-verbal and has a hard time with her vision.&nbsp; &nbsp;</p> <p>When you shop with us, you're shopping to support Riley.&nbsp; Both my husband and I have full-time corporate jobs, but it's just not enough some days with the extra needs.&nbsp; The most recent need is a wheel-chair accessible van that we're saving for.&nbsp;&nbsp;</p> <p><span style="color: rgb(34, 34, 34); font-size: 40px; font-weight: 700;">Refund Policy</span></p> <p>We have a 30-day return policy, which means you have 30 days after receiving your item to request a return.<br><br>To be eligible for a return, your item must be in the same condition that you received it. You’ll also need the receipt or proof of purchase.<br><br>To start a return, you can contact us at&nbsp;<a href="mailto:sara@moonwavesdesign.com">sara@moonwavesdesign.com</a>. If your return is accepted, we’ll&nbsp;provide shipping instructions for you to send back items at your expense.&nbsp;Items sent back to us without first requesting a return will not be accepted.<br><br>You can always contact us for any return questions at&nbsp;<a href="mailto:sara@moonwavesdesign.com">sara@moonwavesdesign.com</a>.</p> <p><b>Damages and issues</b><br>Please inspect your order upon reception and contact us immediately if the item is defective, damaged or if you receive the wrong item so that we can evaluate the issue and make it right. You must notify us within 3 days of receipt of any issues and please photograph proof of damage.</p> <p><b>Exceptions / non-returnable items</b><br>Certain types of items cannot be returned, custom products (such as special orders or personalized items). Please get in touch if you have questions or concerns about your specific item.<br><br>Unfortunately, we cannot accept returns on sale items or gift cards.</p> <p><b>Exchanges</b><br>The fastest way to ensure you get what you want is to return the item you have, and once the return is accepted, make a separate purchase for the new item.</p> <p><b>Refunds</b><br>We will notify you once we’ve received and inspected your return, and let you know if the refund was approved or not. If approved, you’ll be automatically refunded on your original payment method. Please remember it can take some time for your bank or credit card company to process and post the refund too.</p> <h1>Shipping policy</h1> <h3>SHIPPING TIMES</h3> <p>Due to the nature of the products produced at Moon Waves Design, LLC, we ask for a two-week period after purchase until shipping to allow time for custom products and others to be made.&nbsp; We do not keep stock of items, and all items are made to order.</p> <h3>SHIPPING CHARGES</h3> <p>Shipping will be at the expense of the buyer.&nbsp; It's calculated based on the packaging and weight of items.&nbsp;</p> <p>Please note, if a purchaser chooses to return a returnable item, shipping will be at the expense of the purchaser.&nbsp;&nbsp;</p> <h3>DAMAGED MERCHANDISE</h3> <p><em>Please inspect your order immediately upon receipt.</em>&nbsp;If you believe you have received merchandise from&nbsp;Moon Waves Design that is damaged or incorrect (wrong item), please contact email us at&nbsp;contact@moonwavesdesign.com within 3 days of delivery receipt - NO EXCEPTIONS. A partial or full store credit (no refunds to your card) will be issued to your account, not including shipping fees and taxes, once the damaged merchandise is reviewed and approved (a picture MUST be provided with proof of damage).</p> <h4><b>DELIVERED BUT NOT DELIVERED<br></b></h4> <p>All of our shipments include&nbsp;Tracking with Delivery Confirmation. If the tracking information confirms that the item has been delivered to your order address, but you have not received your order, please contact couriers at the numbers below in order to investigate this issue. We cannot be held accountable for packages where tracking information states the package has been delivered to your order address.&nbsp;</p> <table><tbody><tr><td>Courier</td><td>Phone</td></tr><tr><td>USPS</td><td>1-800-275-8777</td></tr><tr><td>UPS</td><td><table><tbody><tr><td>1-800-742-5877</td></tr></tbody></table></td></tr></tbody></table> <p><br></p> {"tmenu_style":"H","default_colors":"N","link_color":"#beabc9","label_color":"#beabc9","icon_color":"#beabc9","main_btn_color":"#beabc9","branded_text_color":"#beabc9","vbp_1_url":"","vbp_2_url":"","vbp_3_url":"","vba_1_url":"https:\/\/moonwavesdesign.ck.page\/newsletter","vba_2_url":"https:\/\/goimagine.com\/caring-economy\/","vba_3_url":"https:\/\/www.facebook.com\/MoonWavesDesign\/"} Moon Waves Design 613 SE Monteiro Dr Port St Lucie A Moon Waves Design 613 SE Monteiro Dr Port St Lucie FL US 34984 sara@moonwavesdesign.com none Y 1637352187 0 4 acct_1Jy4VzG5b6R6M37T 155601,156594,164292,156598,156609,156590,156548,156515 ARJDQGHNDHEZ2 Craft the things. Calm the Soul. https://www.facebook.com/MoonWavesDesign/ https://www.instagram.com/moonwavesdesign/ https://twitter.com/moonwavesdesign/ https://www.pinterest.com/moonwavesdesign/ UA-153605714-2 1157574361253786 moonwavesdesign.com A N 0 0 0 0 0 S All-Star Plan moonwavesdesign 4401_0