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' 
    AND cscart_discussion.company_id = 1
  ) 
WHERE 
  dp.status = 'A' 
  and p.product_id in (
    19860, 19820, 19863, 19865, 19866, 20154, 
    19867, 19868, 19869, 19870, 19871, 
    19872, 19873, 19875, 19874, 19876, 
    20087, 19877, 19878, 19879, 19880, 
    19881, 19882, 19883, 19884, 19885, 
    19886, 19888, 19889, 19890, 19891, 
    19892, 19893, 19894, 19895, 19896, 
    19897, 19898, 19899, 19900, 19901, 
    19902, 19903, 19904, 19905, 19925, 
    19906, 19907, 19908, 19909, 19910, 
    19911, 20576, 20088, 20089, 20091, 
    20092, 20093, 20094, 18661, 18662, 
    19131, 18664, 20724, 20725, 20728, 
    20955, 20956, 20957, 20958, 20959, 
    22277, 20971, 21078, 21102, 20972, 
    20973, 20974, 21103, 21923, 21924, 
    21925, 21926, 20065, 19887, 21749, 
    20723, 20726, 20727
  ) 
GROUP BY 
  p.product_id

Query time 0.00115

JSON explain

{
  "query_block": {
    "select_id": 1,
    "nested_loop": [
      {
        "table": {
          "table_name": "p",
          "access_type": "range",
          "possible_keys": ["PRIMARY"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "rows": 89,
          "filtered": 100,
          "attached_condition": "p.product_id in (19860,19820,19863,19865,19866,20154,19867,19868,19869,19870,19871,19872,19873,19875,19874,19876,20087,19877,19878,19879,19880,19881,19882,19883,19884,19885,19886,19888,19889,19890,19891,19892,19893,19894,19895,19896,19897,19898,19899,19900,19901,19902,19903,19904,19905,19925,19906,19907,19908,19909,19910,19911,20576,20088,20089,20091,20092,20093,20094,18661,18662,19131,18664,20724,20725,20728,20955,20956,20957,20958,20959,22277,20971,21078,21102,20972,20973,20974,21103,21923,21924,21925,21926,20065,19887,21749,20723,20726,20727)",
          "using_index": true
        }
      },
      {
        "table": {
          "table_name": "cscart_discussion",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY", "object_id", "idx_company_id"],
          "key": "object_id",
          "key_length": "10",
          "used_key_parts": ["object_id", "object_type", "company_id"],
          "ref": ["lillyshop_lillyshop.p.product_id", "const", "const"],
          "rows": 1,
          "filtered": 100,
          "index_condition": "cscart_discussion.object_type = 'P'"
        }
      },
      {
        "table": {
          "table_name": "dp",
          "access_type": "ref",
          "possible_keys": ["thread_id", "thread_id_2"],
          "key": "thread_id_2",
          "key_length": "6",
          "used_key_parts": ["thread_id", "status"],
          "ref": ["lillyshop_lillyshop.cscart_discussion.thread_id", "const"],
          "rows": 2,
          "filtered": 100,
          "index_condition": "dp.`status` = 'A'"
        }
      }
    ]
  }
}