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 (
    30864, 30865, 30866, 30867, 30868, 30869, 
    30870, 30871, 30872, 30873, 30874, 
    30875, 30876, 30877, 30878, 30879, 
    30880, 30881, 30882, 30883, 30884, 
    30885, 30886, 30887, 30888, 30889, 
    30890, 30891, 30892, 30893, 30894, 
    30895
  ) 
  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.00136

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "76.81"
    },
    "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": 32,
        "rows_produced_per_join": 6,
        "filtered": "19.99",
        "index_condition": "(`portal`.`q_product_prices`.`product_id` in (30864,30865,30866,30867,30868,30869,30870,30871,30872,30873,30874,30875,30876,30877,30878,30879,30880,30881,30882,30883,30884,30885,30886,30887,30888,30889,30890,30891,30892,30893,30894,30895))",
        "cost_info": {
          "read_cost": "75.53",
          "eval_cost": "1.28",
          "prefix_cost": "76.81",
          "data_read_per_join": "153"
        },
        "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
30864 36.000000
30865 36.000000
30866 54.000000
30867 36.000000
30868 36.000000
30869 54.000000
30870 36.000000
30871 36.000000
30872 36.000000
30873 27.000000
30874 36.000000
30875 36.000000
30876 36.000000
30877 36.000000
30878 36.000000
30879 54.000000
30880 36.000000
30881 36.000000
30882 54.000000
30883 36.000000
30884 36.000000
30885 36.000000
30886 36.000000
30887 36.000000
30888 36.000000
30889 36.000000
30890 36.000000
30891 36.000000
30892 36.000000
30893 36.000000
30894 54.000000
30895 36.000000