SQL_SMALL_RESULT is one of three legacy MySQL SELECT options (along with SQL_BIG_RESULT and SQL_BUFFER_RESULT) that influence how temporary result sets are handled during DISTINCT or GROUP BY operations. When specified, MySQL assumes the final grouped or distinct output will contain only a small number of rows. The optimizer therefore prefers storing intermediate data in memory using temporary tables hashed by key values, instead of writing large sorted files to disk. Because modern MySQL versions automatically estimate result-set sizes, SQL_SMALL_RESULT rarely changes performance and is often unnecessary. However, in edge cases where the optimizer misjudges cardinality—especially on complex views or when statistics are stale—explicitly declaring SQL_SMALL_RESULT can force a faster in-memory strategy. The clause has no effect on the data returned to the client and is ignored when neither DISTINCT nor GROUP BY is present. Other database systems do not support the keyword; using it outside MySQL causes a syntax error.
MySQL 3.23
It can reduce query time by keeping temporary DISTINCT or GROUP BY results in memory, avoiding disk I/O on genuinely small result sets.
No. It affects only the internal execution plan. The client receives identical data with or without the hint.
No. They are mutually exclusive. Specify only one hint per SELECT statement.
No. Other popular databases do not recognize the keyword and will raise a syntax error.