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

Query time 0.00207

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "2.91"
    },
    "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.90",
            "eval_cost": "0.10",
            "prefix_cost": "1.00",
            "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.77",
            "eval_cost": "0.10",
            "prefix_cost": "1.87",
            "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.30",
            "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.91",
            "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
976 en <p><span class="display-block"></span><span class="display-block"></span><span class="display-block"></span></p> <p>Hello and welcome to my shop. I’m glad you stopped by. My name is Dawn and I have been creating in one form or another for more than 40 years.</p><p>I make home decor items such as candle mats and table runners. I also offer a wide variety of fun projects and can provide everything you need to make them. I love Christmas and offer lots of colorful items to make your home festive this holiday season.<br></p> <p>Recent 5 star reviews...</p> <p>"Absolutely loved! Packaged really well, instructions clear and great communication with the seller. Would buy again!"</p> <p></p> <p>"When I saw this print, I just could not pass it up!! I had some questions about sizes and the owner of this shop was very helpful and responded very quickly. It was shipped quickly and arrived in perfect condition. I have glass to fit my kitchen table, I used this round table topper in between the glass and the wood. It adds the perfect touch!!!"</p> <p></p> <p>"Beautiful!! I love the color combinations of the batik fabrics! Thanks for sharing your talent with others."<br></p> <p>"This is so nicely made. It is gorgeously composed and well-crafted with care and pride. Even the hanging hardware and label are perfectly done. Thank you! I am so happy with my beautiful purchase."</p> <p>"This is much more gorgeous than the pictures because of the delightful color combinations and particularly the delicate touches of orange. It is a perfect addition to my collection."</p> <p></p> <p><br></p> <p></p> <p><span class="display-block"><br></span></p> <p></p> <p><strong>Custom Orders <br></strong></p> <p>You can contact me directly by using the <strong>Contact the Maker</strong> button at the top of the page.</p> <p><strong>The basics<br></strong></p> <p>I have found that creating an original art quilt takes time. Plan on 5 - 6 weeks; more for larger sizes. The amount of detail will also add to the time it takes. I will have a better idea once we have discussed what you are looking for and will provide you with a time estimate and approximate start date.</p> <p>The largest size I can do as one panel/quilt is 40” square. Larger sizes will be broken up into multiple panels.</p> <p>Once we have talked and determined the details of your art quilt I will send you a quote spelling out the details of your order. Upon acceptance of that quote I will create a custom listing for you for the initial deposit. <strong>This deposit is non-refundable should you cancel the order.</strong> Changes or additions to the original quilt design (as described in the quote and deposit listing) may result in additional charges to you and will be due as part of the final payment. The final amount will be due upon completion of the quilt and before it is shipped.</p> <p><strong>Please note: Quilts that contain subject matter that is so specific to you that they can't be sold to anyone else will require a 100% non-refundable deposit before work is started.</strong><br></p> <p><strong>Returns and exchanges</strong> </p> <p>I <b>do not</b> accept returns on <b>sale items and custom orders</b>. </p> <p>For all other items please contact me within 2 days of delivery.&nbsp; The item must be shipped back to me via Priority mail, or something comparable to how it was shipped to you, within 5 days of delivery. </p> <p><b>Conditions of return</b> </p> <p>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. Your refund will be issued once I have received your item(s) and determined their condition. <br></p> <p> <b>I want to hear from you</b>&nbsp; <br></p> <p>Please contact me if you have any questions or concerns and we can work together on a solution. <br></p> <p><br></p> <p><br></p> {"tmenu_style":"H","default_colors":"N","link_color":"#17376e","label_color":"#0098cf","icon_color":"#20124d","main_btn_color":"#005aa4","branded_text_color":"#00afe7","vbp_1_url":"https:\/\/dawnandersen.com\/season\/","vbp_2_url":"https:\/\/dawnandersen.com\/custom-orders-en\/","vbp_3_url":"","vba_1_url":"https:\/\/dawnandersen.com\/diy-quilt-kits\/","vba_2_url":"https:\/\/dawnandersen.com\/season\/spring\/","vba_3_url":"https:\/\/dawnandersen.com\/season\/summer\/"} Dawn Andersen Art 70 Kussler Way Cropseyville A Dawn Andersen Art 70 Kussler Way Cropseyville NY US 12052 artquiltsbydawn@gmail.com none Y 1596646704 0 a:4:{s:14:"company_fields";a:2:{i:37;s:4:"Dawn";i:38;s:8:"Andersen";}s:15:"admin_firstname";s:4:"Dawn";s:14:"admin_lastname";s:8:"Andersen";s:6:"fields";a:0:{}} 3 acct_1FyLWrI3WLRB1lYb 292828,235227,280990,212685,223917,284964,215721,127237,262383,294707,285027,296186 UA-177103124-1 DIY downloads, art and art projects, Christmas items, and more https://www.instagram.com/artquiltsbydawn/ https://www.pinterest.com/artquiltsbydawn0362 <p>All of my items are handmade by me in a smoke free home. We have one resident kitty so be sure to let me know if you are allergic when ordering. </p> UA-177103124-1 dawnandersen.com A N 0 0 0 0 0 S Professional Plan dawnandersenart 5.0000 976_23670