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 (
    148, 180, 18, 16, 4, 5, 23, 24, 1, 22, 149, 
    227, 190, 189, 245, 238, 239, 242, 243, 
    241, 240, 214, 217, 218, 207, 59, 58, 
    60, 172, 134, 135, 168, 167, 169, 42, 
    39, 40, 205, 37, 74, 73, 71, 75, 72, 70, 
    156, 175, 43, 76, 56, 57, 30, 246, 208, 
    173, 229, 211, 210, 209, 67, 25, 213, 
    215, 226, 154, 53, 52, 228, 161, 165, 
    166, 86, 106, 105, 247, 101, 33, 32, 163, 
    244, 212, 155, 55, 69, 206, 184, 183, 
    133, 132, 125, 120, 223, 225, 224, 146, 
    147
  ) 
GROUP BY 
  p.product_id

Query time 0.00118

JSON explain

{
  "query_block": {
    "select_id": 1,
    "filesort": {
      "sort_key": "p.product_id",
      "temporary_table": {
        "nested_loop": [
          {
            "table": {
              "table_name": "dp",
              "access_type": "ALL",
              "possible_keys": ["thread_id", "thread_id_2"],
              "rows": 17,
              "filtered": 100,
              "attached_condition": "dp.`status` = 'A'"
            }
          },
          {
            "table": {
              "table_name": "cscart_discussion",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY", "object_id", "idx_company_id"],
              "key": "PRIMARY",
              "key_length": "3",
              "used_key_parts": ["thread_id"],
              "ref": ["n764025_kutubminar123.dp.thread_id"],
              "rows": 1,
              "filtered": 100,
              "attached_condition": "cscart_discussion.company_id = 1 and cscart_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": ["n764025_kutubminar123.cscart_discussion.object_id"],
              "rows": 1,
              "filtered": 100,
              "attached_condition": "p.product_id in (148,180,18,16,4,5,23,24,1,22,149,227,190,189,245,238,239,242,243,241,240,214,217,218,207,59,58,60,172,134,135,168,167,169,42,39,40,205,37,74,73,71,75,72,70,156,175,43,76,56,57,30,246,208,173,229,211,210,209,67,25,213,215,226,154,53,52,228,161,165,166,86,106,105,247,101,33,32,163,244,212,155,55,69,206,184,183,133,132,125,120,223,225,224,146,147)",
              "using_index": true
            }
          }
        ]
      }
    }
  }
}

Result

product_id discussion_amount_posts
1 1
5 1
23 1
167 1
172 1
224 2
228 2
238 1
239 1
242 2