SELECT 
  p.product_id, 
  ifnull(
    count(dp.post_id), 
    0
  ) as discussion_amount_posts 
FROM 
  tmall_discussion 
  INNER JOIN tmall_products as p ON (
    tmall_discussion.object_id = p.product_id
  ) 
  INNER JOIN tmall_discussion_posts as dp ON (
    tmall_discussion.thread_id = dp.thread_id 
    AND tmall_discussion.object_type = 'P'
  ) 
WHERE 
  dp.status = 'A' 
  and p.product_id in (
    12, 17, 148, 180, 187, 232, 230, 231, 18, 
    16, 4, 5, 23, 24, 170, 1, 22, 149, 227, 
    78
  ) 
GROUP BY 
  p.product_id

Query time 0.01369

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.168529282,
    "filesort": {
      "sort_key": "p.product_id",
      "temporary_table": {
        "nested_loop": [
          {
            "table": {
              "table_name": "dp",
              "access_type": "ALL",
              "possible_keys": ["thread_id", "thread_id_2"],
              "loops": 1,
              "rows": 50,
              "cost": 0.01785585,
              "filtered": 100,
              "attached_condition": "dp.`status` = 'A'"
            }
          },
          {
            "table": {
              "table_name": "tmall_discussion",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY", "object_id"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["thread_id"],
              "ref": ["tmall.dp.thread_id"],
              "loops": 50,
              "rows": 1,
              "cost": 0.0866561,
              "filtered": 100,
              "attached_condition": "tmall_discussion.object_type = 'P'"
            }
          },
          {
            "table": {
              "table_name": "p",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["product_id"],
              "ref": ["tmall.tmall_discussion.object_id"],
              "loops": 50,
              "rows": 1,
              "cost": 0.03187615,
              "filtered": 100,
              "attached_condition": "p.product_id in (12,17,148,180,187,232,230,231,18,16,4,5,23,24,170,1,22,149,227,78)",
              "using_index": true
            }
          }
        ]
      }
    }
  }
}

Result

product_id discussion_amount_posts
1 3
5 3
23 1
78 1
148 3
149 3