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

Query time 0.00248

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "2.80"
    },
    "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.71",
            "eval_cost": "0.10",
            "prefix_cost": "1.76",
            "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.18",
            "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.80",
            "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
239 en <p>Unique fine art photography directly from the artist Bob Estrin to enrich your home design needs. Bob Estrin's photography will perfectly blend in with your interior and become a charming piece for your living room, bedroom, kitchen, hallway or office.</p> <p><strong>Sample video below </strong>of Bob walking in a slot canyon in Utah.</p> <p><a href="http://www.bobestrin.com/picts/mvi-7007_xctuqb4q.mov" target="_blank" class="editor-rtfLink"><strong>Click here to view the video</strong></a></p> <p><strong>Customer Comments:<br><br>"</strong>B<span class="expandable-text a-text-quote"><span class="expandable-expanded-text">ob’s prints are of the highest quality and an incredible value. Excellent materials and execution. Customer service is wonderful. I made a mistake with my order and Bob quickly resolved it for me and was more than fair. If you purchase a print from Bob you will be very happy you did!</span> </span><span class="expandable-action expandable-reduce-action"><span class="a-declarative" data-action="reduce-text" data-reduce-text="{}">" </span> </span> </p> <p>"Amazing work, had some questions from the seller wrote back very timely. I'm so very lucky to have your photo in my house."</p> <p>"We love the photograph and get lots of compliments when customers come into our business."</p> <p>&nbsp;"Beautiful panoramic photograph by Bob, so beautiful on the wall with my wilderness theme. Highly recommend!! Great customer service as well."</p> <p>"A beautiful photograph of original Bristle Pine Cone tree very pleased with the size and nicely matted; also happy to get to know the photographer in his bio included with the purchase. An absolute satisfied sale."</p> <p>"Got this as a gift for my Ma. She absolutely loved it! The photograph is hauntingly beautiful, and it stands out so well in her living room!"</p> <p><strong>Artist Bio</strong></p> <p>Two of my great passions in life are travel and photography. Through my photography, I seek to document my personal experiences, capture scenes and events as I see them, and share with others the beauty and diversity of the world I've seen.</p> <p>I grew up in a Northwest suburb of Chicago and became fascinated with photography at an early age. This led to my first 35mm camera purchase in 1971 for a high school black & white photography class. This eventually progressed to my receiving my Bachelor of Arts degree in professional photography from Southern Illinois University.</p> <p>&nbsp;After working in the photography field for a few years, I chose to go back to school to learn computer programming and worked for many years as a Programmer/Analyst and System Analyst. My frequent visits and family connection to Arizona assisted in my decision to move to Arizona in 1999.</p> <p>With the beauty of the Southwest all around me, I have recaptured my passion for photography. It is my goal as an artist and photographer to encourage this closer examination of ordinary things by presenting them in an unusual context. While my photographic subjects vary widely, I find myself repeatedly drawn to landscapes and objects from the past such as cars and ghost towns as well as the influence of man on both of these.</p> <p>Fine photograph is not only the creation of the original camera exposure but also the result of significant technical and aesthetic consideration while making the final print. This allows me to not only record a literal moment in time but rather the emotion or experience of the moment.&nbsp;</p> <p>Photography is the medium of choice for my creative expression. I am still excited about the power and magic of photography and its ability to capture my unique selective perception of the moment in a form that I can share with others.</p> <p>Estrin displays his art around Arizona at venues including solo exhibitions at the ASU Gammage Auditorium, Boyce Thompson Arboretum, Tucson Jewish Community Center Gallery, and the Peoria and Gilbert Arizona libraries.&nbsp;</p> <p>His art has been exhibited at the West Valley Art Museum and the Arizona Art Museum for Youth. Estrin’s art is collected by individuals as well as found in city and corporate collections. He has been featured in the Arizona Republic newspaper and selected as Phoenix Magazine’s artist of the month.<br></p> <p><strong>Make things better:&nbsp;</strong> I appreciate your business and that you have selected my artwork for your walls among the many choices you have.&nbsp; If you encounter any issues or problems, contact me thru Goimagine and receive a response within 24 hours.&nbsp; In most cases, I can fix the issue immediately.&nbsp; <br></p> <p><strong>Return policy for matted prints and individual paper prints:</strong></p> <p>Refunds will only be issued within 30 days of shipment delivery, minus all shipping costs, upon return of item/items in original condition.&nbsp; Return shipping is at the customer's expense. <br></p> <p><strong>Return policy for Canvas, Aluminum or Framed photographs:&nbsp; </strong>For these types of custom photographs returns are not available since they are made to order.&nbsp; <br></p> <p><strong>Cancellation Policy for Canvas, Aluminum and Framed photographs:&nbsp; </strong>These types of photographs cannot be canceled once the custom photograph is started to be produced even if the product is not yet completed or shipped out.&nbsp; The customer can contact the store to see if cancellation is possible if the creation of the customized product has not been started yet.<br><br><strong>Product arrives damaged or defective (All products):&nbsp; </strong>Notify the store of a damaged or defective product within 7 days of arrival for Return Merchandise Authorization.&nbsp; A replacement will be sent when the item is returned.&nbsp; <br></p> <p><strong>Shipping:</strong>&nbsp; Most items ship out in 1 - 3 days.&nbsp; Canvas and framed photographs ship out in 4-5 days.<strong><br><br>Contact Email:</strong>&nbsp; <span class="gI">photographyartwork1@gmail.com</span>&nbsp; This contact method will support sending attachments or images.<br></p> <p></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":"https:\/\/bobestrinphotography.goimagine.com\/landscapes\/","vbp_2_url":"https:\/\/bobestrinphotography.goimagine.com\/southwest\/","vbp_3_url":"https:\/\/bobestrinphotography.goimagine.com\/items-from-the-past\/architecture\/","vba_1_url":"","vba_2_url":"https:\/\/bobestrinphotography.goimagine.com\/my-favorites\/","vba_3_url":"https:\/\/bobestrinphotography.goimagine.com\/route-66\/"} Bob Estrin Photography 2060 E Huron Ct. Gilbert A Bob Estrin Photography 2060 E Huron Ct. Gilbert AZ US 85234 photographyartwork1@gmail.com none Y 1585849592 0 a:4:{s:14:"company_fields";a:2:{i:37;s:6:"Robert";i:38;s:6:"Estrin";}s:15:"admin_firstname";s:6:"Robert";s:14:"admin_lastname";s:6:"Estrin";s:6:"fields";a:0:{}} 3 acct_1GTY8TLLsLaKwx96 46435,47913,43836,43812,47918,48379,26928,46466 UA-7645313-3 9R5GQRFSGMPL8 Artwork for your walls to bring creativity to your home life <p>Select the "Follow Maker" button to be notified of new artwork.</p> UA-7645313-3 A {"items_per_file":"2500","time_from":"","time_to":""} N 0 0 0 0 0 S Professional Plan bob-estrin-photography-en 239_0