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 (
    31047, 31053, 31068, 31074, 31082, 31089, 
    31091, 31117, 31129, 31151, 31155, 
    31156, 10422, 10429, 10431, 10432, 
    10433, 10027, 10028, 4579, 4580, 3352, 
    3353
  ) 
  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.00070

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "65.01"
    },
    "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": 30,
        "rows_produced_per_join": 5,
        "filtered": "19.99",
        "index_condition": "(`portal`.`q_product_prices`.`product_id` in (31047,31053,31068,31074,31082,31089,31091,31117,31129,31151,31155,31156,10422,10429,10431,10432,10433,10027,10028,4579,4580,3352,3353))",
        "cost_info": {
          "read_cost": "63.81",
          "eval_cost": "1.20",
          "prefix_cost": "65.01",
          "data_read_per_join": "143"
        },
        "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
3352 1629.000000
3353 1545.000000
4579 999.000000
4580 1399.000000
10027 619.000000
10028 1392.000000
10422 675.000000
10429 149.000000
10431 119.000000
10432 349.000000
10433 89.000000
31047 36.000000
31053 36.000000
31068 144.000000
31074 36.000000
31082 36.000000
31089 54.000000
31091 63.000000
31117 36.000000
31129 72.000000
31151 54.000000
31155 81.000000
31156 36.000000