SELECT 
  q_product_prices.product_id, 
  MIN(
    IF(
      q_product_prices.percentage_discount = 0, 
      q_product_prices.price, 
      q_product_prices.price - (
        q_product_prices.price * q_product_prices.percentage_discount
      )/ 100
    )
  ) AS price 
FROM 
  q_product_prices 
WHERE 
  q_product_prices.product_id IN (
    51125, 51103, 51099, 51094, 51078, 40981, 
    40982, 40983, 40984, 40985, 40986, 
    40987, 40988, 40989, 40990, 40991, 
    40992, 40993, 40994, 40995, 40996, 
    40997, 40998, 40999, 41000, 41001, 
    41002, 41003, 41004, 41005
  ) 
  AND q_product_prices.lower_limit = 1 
  AND q_product_prices.usergroup_id IN (0, 1) 
GROUP BY 
  q_product_prices.product_id

Query time 0.00095

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "83.21"
    },
    "grouping_operation": {
      "using_filesort": false,
      "table": {
        "table_name": "q_product_prices",
        "access_type": "range",
        "possible_keys": [
          "usergroup",
          "product_id",
          "lower_limit",
          "usergroup_id"
        ],
        "key": "product_id",
        "used_key_parts": [
          "product_id"
        ],
        "key_length": "3",
        "rows_examined_per_scan": 38,
        "rows_produced_per_join": 7,
        "filtered": "19.99",
        "index_condition": "(`portal`.`q_product_prices`.`product_id` in (51125,51103,51099,51094,51078,40981,40982,40983,40984,40985,40986,40987,40988,40989,40990,40991,40992,40993,40994,40995,40996,40997,40998,40999,41000,41001,41002,41003,41004,41005))",
        "cost_info": {
          "read_cost": "81.69",
          "eval_cost": "1.52",
          "prefix_cost": "83.21",
          "data_read_per_join": "182"
        },
        "used_columns": [
          "product_id",
          "price",
          "percentage_discount",
          "lower_limit",
          "usergroup_id"
        ],
        "attached_condition": "((`portal`.`q_product_prices`.`lower_limit` = 1) and (`portal`.`q_product_prices`.`usergroup_id` in (0,1)))"
      }
    }
  }
}

Result

product_id price
40981 76.000000
40982 75.000000
40983 75.000000
40984 75.000000
40985 115.000000
40986 115.000000
40987 89.000000
40988 89.000000
40989 89.000000
40990 89.000000
40991 89.000000
40992 89.000000
40993 89.000000
40994 89.000000
40995 89.000000
40996 89.000000
40997 89.000000
40998 89.000000
40999 89.000000
41000 149.000000
41001 149.000000
41002 149.000000
41003 149.000000
41004 115.000000
41005 115.000000
51078 49.000000
51094 25.000000
51099 49.000000
51103 49.000000
51125 39.000000