SELECT 
  discussion.object_id AS product_id, 
  AVG(discussion_rating.rating_value) AS average_rating, 
  discussion.type AS discussion_type, 
  discussion.thread_id AS discussion_thread_id 
FROM 
  discussion 
  LEFT JOIN discussion_posts ON discussion_posts.thread_id = discussion.thread_id 
  AND discussion_posts.status = "A" 
  LEFT JOIN discussion_rating ON discussion.thread_id = discussion_rating.thread_id 
  AND discussion_rating.post_id = discussion_posts.post_id 
  AND discussion_rating.rating_value != 0 
WHERE 
  discussion.object_id IN (
    292255, 292063, 131731, 131730, 131723, 
    131720, 131733, 142583, 60296, 69189, 
    65542, 144618, 144619, 65546, 20850, 
    22976, 41008, 40967, 26745, 37628, 
    70620, 36514, 23700, 23695, 49591, 
    23349, 26924, 33770, 33713, 47186, 
    45116, 38492, 45620
  ) 
  AND discussion.object_type = "P" 
GROUP BY 
  discussion.object_id

Query time 0.00987

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "90.18"
    },
    "grouping_operation": {
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "discussion",
            "access_type": "range",
            "possible_keys": [
              "object_id"
            ],
            "key": "object_id",
            "used_key_parts": [
              "object_id",
              "object_type"
            ],
            "key_length": "6",
            "rows_examined_per_scan": 33,
            "rows_produced_per_join": 33,
            "filtered": "100.00",
            "index_condition": "((`goimagine`.`discussion`.`object_id` in (292255,292063,131731,131730,131723,131720,131733,142583,60296,69189,65542,144618,144619,65546,20850,22976,41008,40967,26745,37628,70620,36514,23700,23695,49591,23349,26924,33770,33713,47186,45116,38492,45620)) and (`goimagine`.`discussion`.`object_type` = 'P'))",
            "cost_info": {
              "read_cost": "52.52",
              "eval_cost": "3.30",
              "prefix_cost": "55.82",
              "data_read_per_join": "792"
            },
            "used_columns": [
              "thread_id",
              "object_id",
              "object_type",
              "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.discussion.thread_id",
              "const"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 58,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "8.26",
              "eval_cost": "5.80",
              "prefix_cost": "69.88",
              "data_read_per_join": "25K"
            },
            "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": 58,
            "filtered": "100.00",
            "cost_info": {
              "read_cost": "14.50",
              "eval_cost": "5.80",
              "prefix_cost": "90.18",
              "data_read_per_join": "928"
            },
            "used_columns": [
              "rating_value",
              "post_id",
              "thread_id"
            ],
            "attached_condition": "<if>(is_not_null_compl(discussion_rating), ((`goimagine`.`discussion_rating`.`thread_id` = `goimagine`.`discussion`.`thread_id`) and (`goimagine`.`discussion_rating`.`rating_value` <> 0)), true)"
          }
        }
      ]
    }
  }
}

Result

product_id average_rating discussion_type discussion_thread_id
20850 B 6460
22976 D 9219
23349 D 9684
23695 D 10159
23700 D 10164
26745 D 13504
26924 D 13665
33713 D 20878
33770 D 20941
36514 D 23839
37628 D 24967
38492 D 25847
40967 D 28325
41008 D 28365
45116 D 32545
45620 D 33067
47186 D 34656
49591 D 37077
60296 D 288565
65542 D 366981
65546 D 366985
69189 D 379391
70620 D 382664
131720 D 798510
131723 D 798513
131730 D 798521
131731 D 798522
131733 D 798524
142583 D 880937
144618 D 887012
144619 D 887013
292255 D 3853660