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

Query time 0.00129

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "2.76"
    },
    "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.85",
            "eval_cost": "0.10",
            "prefix_cost": "0.95",
            "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.68",
            "eval_cost": "0.10",
            "prefix_cost": "1.72",
            "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.15",
            "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.76",
            "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
7548 en <p>Hi. Thanks for stopping by to learn a bit about me, and the motivation behind "With Love, David".&nbsp;&nbsp;</p> <p>I've always loved creating, and sold at markets and fairs for quite a number of years, until life took over, putting the creator in me aside for a while.&nbsp; Then, several years ago, I developed an auto-immune disease, one that required me to put my favorite lotions, potions, cleaners and fragrances aside.&nbsp; That's no fun, so the creator in me got back to work, with a goal to create&nbsp; natural products that would moisturize, and sooth my skin.&nbsp; Along the way, I discovered&nbsp; many products I used in my home, were also impacting my health, and decided to do the same for my home, that I was doing for my skin, and work began to create natural products, that clean, freshen and scent my home, without harsh chemicals, fumes, soot or oily residue.&nbsp; Through plenty of trials, setbacks, and steps forward, I've created a line of products that are doing exactly what I had hoped, and my home is becoming a cleaner, easier breathing, and better living home.&nbsp; Best of all, my skin is a lot less angry, and much easier to get along with!&nbsp;&nbsp;</p> <p>Now, it's time to introduce my products to the wider, online audience, and I'll be adding them slowly, over the next several months.&nbsp; &nbsp;I chose Go Imagine for this venture because I love their mission of giving back.&nbsp; For me, it's a blessing to be a blessing, and I'm proud to be a part of the GI story.&nbsp; Our products you see here, also help raise funds for programs near, and dear to us at "With Love, David", and includes Breast Cancer Awareness, and Veterans programs, such as Camp Hope, who provide support for Veterans suffering PTSD, and for Wreaths Across America*, a national event held each year to remember, and honor our Veterans who have completed their walk, and are now at rest.&nbsp;&nbsp;</p> <p>We're happy to be here, and look forward to bringing you cleaner, healthier products for your home and family.&nbsp; &nbsp;Please feel free to reach out with any questions, or to share your thoughts with us at:&nbsp; hello@withlovedavid.com&nbsp;&nbsp;</p> <p>With Love, David</p> <p><br></p> <p><em><span style="color: rgb(127, 127, 127);">* Wreaths Across America is a national effort to remember, and honor Veterans who lay at rest across the country, with a live wreath placed at their gravesite in remembrance of all they gave, including the wreath placed at the Tomb of the Unknown Soldier, in Arlington National Cemetery.&nbsp;&nbsp;&nbsp;If you would like to join us in honoring a Veteran,&nbsp;I would love to count&nbsp;you as a sponsoring member of my&nbsp;"A Grateful American" group.&nbsp; Sponsorships are $15.00 each, are fully tax deductible, and can be completed in just a few minutes, by clicking&nbsp;on the&nbsp;dark blue, "Sponsor a Wreath Here" button, at the bottom of my Wreaths Across American page at&nbsp;&nbsp;</span></em>&nbsp;<a href="https://waahouston.salsalabs.org/2023/p/agratefulamericanrickistockwellsgroup/">https://waahouston.salsalabs.o...</a></p> <h2>Inquiries:</h2> <p>For questions, or additional information on our products, service policies or, if you're interested in&nbsp; offering our products in your shops and markets, please email us at:&nbsp;</p> <p>hello@WithLoveDavid.com</p> <p><strong>FOR WHOLESALE INQUIRIES -&nbsp;</strong>please include the word&nbsp; "Wholesale" in the email subject header, and include your full business name, address, contact information and type of business (retail, online only, store front, craft fairs, seasonal, year round etc.).&nbsp; &nbsp; A copy of your Business License and/or Tax Resale Certificate, with your email is appreciated.&nbsp;&nbsp;</p> <p>Our business hours are Monday-Friday, 9am to 4 pm CST, on Saturdays&nbsp; 9am to noon, and closed Sundays and Holidays.&nbsp; &nbsp;We do our best to respond to all inquiries as quickly as possible, but please allow 24-48 hours for email response.&nbsp; As always, we appreciate you!</p> <p>Sincerely,</p> <p>With Love, David</p> <p><strong><br></strong></p> <h2>Returns, Damages and Shipping:<strong style="color: rgb(51, 51, 51); font-size: 16px;">&nbsp;&nbsp;</strong></h2> <p><b>DAMAGED PRODUCT:&nbsp; DURING DELIVERY</b></p> <p>If upon arrival, any part or all of your order is damaged, please email us at:&nbsp; <strong>h</strong><strong>ello@WithLoveDavid.com</strong>&nbsp;&nbsp;<strong>within 7 days of receipt of product</strong>.&nbsp;&nbsp;</p> <p>Please state "Damage/Replace" in your subject line of your email.&nbsp; Please include your order number and multiple pictures, from all 4 sides, plus top and bottom, of both the packaging, and the damaged product.&nbsp; Within 24-48 hours of receipt of your email, our customer service staff will be in contact with you for further information, and to facilitate our claims process.&nbsp; &nbsp;</p> <p>Customer is required to retain all packaging, and product, until return instructions are provided, in writing, by <em>With Love, David</em>.&nbsp; Failure to retain product and packaging, will void request for refund or reimbursement of return shipping.&nbsp; No exceptions.&nbsp; &nbsp; Customer to return at customer expense.&nbsp; Please provide return tracking # so we can watch for your package to arrive.&nbsp; Customer must also provide copy of receipt of return postage costs, for consideration of reimbursement, once damage claim is processed.&nbsp; &nbsp;</p> <p><em>Please note</em>:&nbsp; &nbsp;Products damaged due to exposure, extremes in temperature upon delivery, or packages that are lost or stolen, after delivery has been made, are not eligible for refund claims processing.&nbsp; Once the product is removed from its protective packaging, we are not responsible for any further damage caused by poor product handling.&nbsp;</p> <p><b>FULL-PRICE ITEMS:</b><br>We hope you are 100% satisfied with your <em>With Love, David</em> purchase. If there is any reason you are not completely satisfied, <em>With Love, David</em>, is happy to offer a No Hassle Refund Policy, for full price purchase, product only, when purchased directly from <em>With Love, David,</em>&nbsp;&nbsp;and returned unopened, unused, and in original packaging, within <em>10 days of your delivery date</em>.&nbsp; Customer is responsible for return shipping/handling costs.&nbsp; &nbsp;On receipt of returned product, <em>With Love David</em>, will inspect product and notify you within 48-72 hours of refund status.&nbsp; Shipping costs are non-refundable.&nbsp;&nbsp;</p> <p>To start return:&nbsp; Please email us at:&nbsp; &nbsp;<em>h</em><em>ello@WithLoveDavid.com</em>.&nbsp; Please state "Return" in the subject line, and&nbsp;reference your&nbsp;order number, and order confirmation from your purchase, in your email.&nbsp; Also include the reason for your return.&nbsp;&nbsp;</p> <p><strong>FINAL RETURN APROVA</strong>L<em>:&nbsp; &nbsp;</em></p> <p><em>All&nbsp; returned products</em>, will be inspected on return receipt at <em>With Love, David, </em>before final approval of refund is granted.&nbsp; &nbsp;You will be notified within 48-72 hours of refund status, (excluding weekends and holidays).&nbsp; Product must be returned in new, unopened, unused condition, and in original packaging.&nbsp; Please be careful to pack your return items for safe transit.&nbsp; Items received damaged on return, due to improper packaging by customer, are not eligible for refund.&nbsp; &nbsp; &nbsp;Please contact us at "hello@WithLoveDavid.com" with any questions or concerns.&nbsp; &nbsp;&nbsp;</p> <p><span class="elementor-icon-list-text">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><br><b>RETURN PROCESSING:&nbsp; Approved and Unauthorized Returns</b><br><span class="elementor-icon-list-text">Please email <em>h</em><em>ello@WithLoveDavid.com, </em>to initiate a return request<em>.&nbsp;&nbsp;</em>&nbsp; Please state "Return" and reason for return, in the subject line, and&nbsp;reference your&nbsp;order number, and your order confirmation from your purchase, in your email.&nbsp; &nbsp; <strong>Pr</strong><strong>oduct returned to <em>With Love, David, </em>for any reason<em>,</em> without prior return authorization, are not eligible for refund.&nbsp; In the very rare event an unauthorized return is approved for refund, all shipping costs, as well as a 35% restocking fee will be deducted from any refund amount.</strong>&nbsp; If the reason for your return is not the result of an error by "With Love, David", all shipping costs, as well as a 15% restocking fee will be deducted from any refund amount.&nbsp; The <em>cost of return shipping will be at customer expense.&nbsp; </em>&nbsp;In this instance, we recommend using a tracked service.</span><span class="elementor-icon-list-text"><br></span><br><b>Combined Shipping and Shipping Differentials:&nbsp;&nbsp;</b><br>It is sometimes difficult to calculate shipping costs on multiple items, and <em>With&nbsp;Love, David,</em> looks at this when putting together your order.&nbsp; In the event you purchase multiple items in one order, and with one delivery address only,&nbsp;<em>With Love, David</em>, will combine your shipping as effectively as&nbsp; possible for a safe, efficient delivery of your items, and in the most cost effective manner possible.&nbsp; In the event there is a shipping differential in excess of $2.50, a credit will be processed.&nbsp;</p> <p><br></p> {"tmenu_style":"H","default_colors":"N","link_color":"#007d89","label_color":"#007377","icon_color":"#007377","main_btn_color":"#e06666","branded_text_color":"#007377","vbp_1_url":"","vbp_2_url":"https:\/\/goimagine.com\/bath-oil-bomb\/","vbp_3_url":"https:\/\/withlovedavid.com\/exfoliating-sugar-scrub-and-soap-bar\/","vba_1_url":"","vba_2_url":"","vba_3_url":""} With Love, David Missouri City A With Love, David Missouri City TX US 77459 hello@withlovedavid.com +17133063773 none Y 1662587842 0 4 acct_1LlI5qAxumkuhzEo 300415,300401,305125,286336,276275,264503,264673 YNN5KKZLBAN4U Artisan Crafted Alternative's for a Naturally Clean, Easy Breathing Home withlovedavid2.com A {"items_per_file":"2500","time_from":"","time_to":""} N 0 0 0 0 0 S All-Star Plan withlovedavid 7548_0