SELECT 
  p.product_id, 
  ifnull(
    count(dp.post_id), 
    0
  ) as discussion_amount_posts 
FROM 
  cscart_discussion 
  INNER JOIN cscart_products as p ON (
    cscart_discussion.object_id = p.product_id
  ) 
  INNER JOIN cscart_discussion_posts as dp ON (
    cscart_discussion.thread_id = dp.thread_id 
    AND cscart_discussion.object_type = 'P'
  ) 
WHERE 
  dp.status = 'A' 
  and p.product_id in (
    2187, 2260, 1861, 1747, 1780, 1797, 1823, 
    1782, 1798, 1772, 1755, 2028, 2118, 
    2116, 2117, 1966, 1967, 1965, 2026, 
    2027, 2131, 1938, 2025, 2062, 2369, 
    1856, 2205, 1846, 1885, 1873, 1824, 
    1869, 2004, 2140, 2139, 2141, 2150, 
    1935, 2003, 2007, 2076, 1867, 2029, 
    2361, 1825, 1826, 2390, 2391, 2270, 
    2272, 2273, 2308, 2378, 2220, 2022, 
    2015, 1980, 1976, 1927, 2058, 1975, 
    1964, 2136, 1749, 1973, 2339, 1974, 
    2354, 1972, 2352, 2030, 2269, 2289, 
    2167, 2128, 1968, 1969, 2192, 2297, 
    2037
  ) 
GROUP BY 
  p.product_id

Query time 0.00037

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "1.47"
    },
    "grouping_operation": {
      "using_temporary_table": true,
      "using_filesort": false,
      "nested_loop": [
        {
          "table": {
            "table_name": "dp",
            "access_type": "ALL",
            "possible_keys": [
              "thread_id",
              "thread_id_2"
            ],
            "rows_examined_per_scan": 5,
            "rows_produced_per_join": 1,
            "filtered": "20.00",
            "cost_info": {
              "read_cost": "1.01",
              "eval_cost": "0.10",
              "prefix_cost": "1.11",
              "data_read_per_join": "448"
            },
            "used_columns": [
              "post_id",
              "thread_id",
              "status"
            ],
            "attached_condition": "(`cscartdevel`.`dp`.`status` = 'A')"
          }
        },
        {
          "table": {
            "table_name": "cscart_discussion",
            "access_type": "eq_ref",
            "possible_keys": [
              "PRIMARY",
              "object_id"
            ],
            "key": "PRIMARY",
            "used_key_parts": [
              "thread_id"
            ],
            "key_length": "3",
            "ref": [
              "cscartdevel.dp.thread_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 0,
            "filtered": "5.24",
            "cost_info": {
              "read_cost": "0.25",
              "eval_cost": "0.01",
              "prefix_cost": "1.46",
              "data_read_per_join": "1"
            },
            "used_columns": [
              "thread_id",
              "object_id",
              "object_type"
            ],
            "attached_condition": "((`cscartdevel`.`cscart_discussion`.`object_id` in (2187,2260,1861,1747,1780,1797,1823,1782,1798,1772,1755,2028,2118,2116,2117,1966,1967,1965,2026,2027,2131,1938,2025,2062,2369,1856,2205,1846,1885,1873,1824,1869,2004,2140,2139,2141,2150,1935,2003,2007,2076,1867,2029,2361,1825,1826,2390,2391,2270,2272,2273,2308,2378,2220,2022,2015,1980,1976,1927,2058,1975,1964,2136,1749,1973,2339,1974,2354,1972,2352,2030,2269,2289,2167,2128,1968,1969,2192,2297,2037)) and (`cscartdevel`.`cscart_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": [
              "cscartdevel.cscart_discussion.object_id"
            ],
            "rows_examined_per_scan": 1,
            "rows_produced_per_join": 0,
            "filtered": "100.00",
            "using_index": true,
            "cost_info": {
              "read_cost": "0.01",
              "eval_cost": "0.01",
              "prefix_cost": "1.48",
              "data_read_per_join": "245"
            },
            "used_columns": [
              "product_id"
            ]
          }
        }
      ]
    }
  }
}