SELECT 
  p.product_id, 
  ifnull(
    count(dp.post_id), 
    0
  ) as discussion_amount_posts 
FROM 
  jmj_discussion 
  INNER JOIN jmj_products as p ON (
    jmj_discussion.object_id = p.product_id
  ) 
  INNER JOIN jmj_discussion_posts as dp ON (
    jmj_discussion.thread_id = dp.thread_id 
    AND jmj_discussion.object_type = 'P'
  ) 
WHERE 
  dp.status = 'A' 
  and p.product_id in (
    1705, 1730, 1654, 1662, 1713, 1733, 1682, 
    1675, 1702, 1728, 1719, 1511, 1517, 
    1523, 1526, 1645, 1647, 1670, 1659, 
    1656, 1723, 1668, 1679, 1696, 1731, 
    1699, 1732, 1707, 1697, 1735, 1695, 
    1686, 1734, 1721, 1729, 814, 816, 817, 
    818, 819, 820, 821, 822, 823, 825, 826, 
    827, 828, 895, 899, 901, 902, 813, 1460, 
    830, 868, 869, 870, 904, 905, 906, 907, 
    908, 909, 917, 920, 921, 922, 923, 924, 
    1105, 1109, 1110, 1111, 1112, 1113, 
    1114, 1115, 1116, 1117, 1118, 1119, 
    1120, 1122, 1123, 1150, 1151, 1152, 
    1059, 1060, 1032, 1033, 1034, 1035, 
    1036, 1037
  ) 
GROUP BY 
  p.product_id

Query time 0.00085

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "11.08"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": true,
      "cost_info": {
        "sort_cost": "0.37"
      },
      "nested_loop": [
        {
          "table": {
            "table_name": "dp",
            "access_type": "ALL",
            "possible_keys": [
              "thread_id",
              "thread_id_2"
            ],
            "rows_examined_per_scan": 25,
            "rows_produced_per_join": 2,
            "filtered": "10.00",
            "cost_info": {
              "read_cost": "6.78",
              "eval_cost": "0.50",
              "prefix_cost": "7.28",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "post_id",
              "thread_id",
              "status"
            ],
            "attached_condition": "(`jmj_test`.`dp`.`status` = 'A')"
          }
        },
        {
          "table": {
            "table_name": "jmj_discussion",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "object_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "thread_id"
            ],
            "key_length": "3",
            "ref": [
              "jmj_test.dp.thread_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 0,
            "filtered": "14.63",
            "cost_info": {
              "read_cost": "2.50",
              "eval_cost": "0.07",
              "prefix_cost": "10.28",
              "data_read_per_join": "8"
            },
            "used_columns": [
              "thread_id",
              "object_id",
              "object_type"
            ],
            "attached_condition": "((`jmj_test`.`jmj_discussion`.`object_id` in (1705,1730,1654,1662,1713,1733,1682,1675,1702,1728,1719,1511,1517,1523,1526,1645,1647,1670,1659,1656,1723,1668,1679,1696,1731,1699,1732,1707,1697,1735,1695,1686,1734,1721,1729,814,816,817,818,819,820,821,822,823,825,826,827,828,895,899,901,902,813,1460,830,868,869,870,904,905,906,907,908,909,917,920,921,922,923,924,1105,1109,1110,1111,1112,1113,1114,1115,1116,1117,1118,1119,1120,1122,1123,1150,1151,1152,1059,1060,1032,1033,1034,1035,1036,1037)) and (`jmj_test`.`jmj_discussion`.`object_type` = 'P'))"
          }
        },
        {
          "table": {
            "table_name": "p",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "product_id"
            ],
            "key_length": "3",
            "ref": [
              "jmj_test.jmj_discussion.object_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 0,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "0.37",
              "eval_cost": "0.07",
              "prefix_cost": "10.72",
              "data_read_per_join": "1K"
            },
            "used_columns": [
              "product_id"
            ]
          }
        }
      ]
    }
  }
}