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

Query time 0.00137

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