SELECT 
  cscart_discussion.object_id AS product_id, 
  AVG(
    cscart_discussion_rating.rating_value
  ) AS average_rating, 
  cscart_discussion.type AS discussion_type, 
  cscart_discussion.thread_id AS discussion_thread_id 
FROM 
  cscart_discussion 
  LEFT JOIN cscart_discussion_posts ON cscart_discussion_posts.thread_id = cscart_discussion.thread_id 
  AND cscart_discussion_posts.status = "A" 
  LEFT JOIN cscart_discussion_rating ON cscart_discussion.thread_id = cscart_discussion_rating.thread_id 
  AND cscart_discussion_rating.post_id = cscart_discussion_posts.post_id 
  AND cscart_discussion_rating.rating_value != 0 
WHERE 
  cscart_discussion.object_id IN (291) 
  AND cscart_discussion.object_type = "P" 
  AND cscart_discussion.company_id = 1 
GROUP BY 
  cscart_discussion.object_id

Query time 0.00056

JSON explain

{
  "query_block": {
    "select_id": 1,
    "const_condition": "1",
    "table": {
      "table_name": "cscart_discussion",
      "access_type": "const",
      "possible_keys": ["object_id", "company_id"],
      "key": "object_id",
      "key_length": "10",
      "used_key_parts": ["object_id", "object_type", "company_id"],
      "ref": ["const", "const", "const"],
      "rows": 1,
      "filtered": 100
    },
    "table": {
      "table_name": "cscart_discussion_posts",
      "access_type": "ref",
      "possible_keys": ["thread_id", "thread_id_2"],
      "key": "thread_id",
      "key_length": "3",
      "used_key_parts": ["thread_id"],
      "ref": ["const"],
      "rows": 1,
      "filtered": 100,
      "attached_condition": "trigcond((cscart_discussion_posts.`status` = 'A'))"
    },
    "table": {
      "table_name": "cscart_discussion_rating",
      "access_type": "eq_ref",
      "possible_keys": ["PRIMARY", "thread_id"],
      "key": "PRIMARY",
      "key_length": "3",
      "used_key_parts": ["post_id"],
      "ref": ["egkcysbp_cscartn.cscart_discussion_posts.post_id"],
      "rows": 1,
      "filtered": 100,
      "attached_condition": "trigcond(((cscart_discussion_rating.thread_id = 47) and (cscart_discussion_rating.rating_value <> 0) and trigcond((cscart_discussion_posts.post_id is not null))))"
    }
  }
}

Result

product_id average_rating discussion_type discussion_thread_id
291 D 47