Skip to content

SQL_BIG_RESULT

SELECT SQL_BIG_RESULT product_id, SUM(price) as total_price
FROM product_sales
GROUP BY product_id;
+------------+--------------+
| product_id | total_price |
+------------+--------------+
| 1 | 5000 |
| 2 | 3000 |
| 3 | 7000 |
+------------+--------------+

The given example uses SQL_BIG_RESULT to modify the SELECT statement. This instruction is used when a large amount of data is expected in the result set. With SQL_BIG_RESULT, MySQL directly uses disk-based temporary tables to store the result set, optimizing for situations where the result data is larger than memory. The example calculates the sum of prices (total_price) for each product_id in the product_sales table.