Bug #46211 | SQL_BIG_RESULT, SQL_SMALL_RESULT, SQL_BUFFER_RESULT should be mutually exclusive | ||
---|---|---|---|
Submitted: | 15 Jul 2009 18:16 | Modified: | 8 Dec 2020 17:41 |
Reporter: | Paul DuBois | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Parser | Severity: | S3 (Non-critical) |
Version: | OS: | Any | |
Assigned to: | Assigned Account | CPU Architecture: | Any |
[15 Jul 2009 18:16]
Paul DuBois
[15 Jul 2009 21:46]
MySQL Verification Team
Thank you for the bug report.
[10 Aug 2009 10:10]
Martin Hansson
IMHO: It would not make sense to mix SQL_BIG_RESULT with SQL_SMALL_RESULT. However, both of these should be allowed in combination with SQL_BUFFER_RESULT as they address different issues/bottlenecks. SQL_[BIG|SMALL]_RESULT tells the optimizer how to compute groups or remove duplicates (GROUP BY and DISTINCT constructs, respectively), whereas SQL_BUFFER_RESULT seems to have the intention of alleviating communication bottlenecks between server and client, hence they should be useful even in combination. Example: SELECT SQL_BUFFER_RESULT SQL_SMALL_RESULT MAX(s1.price), (SELECT hires_image FROM sales WHERE date = s1.date and branch = s1.branch and price = max(s1.price)) FROM sales s1 GROUP BY s1.date, s1.branch HAVING MAX(price) > 100; Computing the group might not require that much memory, but sending the result to a client over a narrow bandwidth connection might take long.
[10 Aug 2009 12:53]
Paul DuBois
Martin, thanks for the info. What is the effect if SQL_BIG_RESULT with SQL_SMALL_RESULT are given together? Does one take precedence? Is the effect "undefined"?
[19 May 2010 13:03]
Martin Hansson
Hi Paul, I did some investigation and I agree that intuitively it seems a result can't be big and small at the same time. The names are perhaps not the best. When you look into it is not really a contradiction. - SQL_BIG_RESULT In general a GROUP BY is performed in two steps, a temporary table and a sorting step. There are a bunch of special cases such as reading from an already-sorted index, computing groups on the fly, ORDER BY NULL and what not but they are all exceptions. This flag will turn off the temporary table step and instead do the bulk of the work in the sorting step. This usually involves swapping out to disk (aka filesort). A funny side-effect that could be optimized away is that filesort is _always_ used, even in the special case SELECT pk_col FROM t1 GROUP BY pk_col. - SQL_SMALL_RESULT This tells the optimizer that _if_ we are using temporary tables, we should try to fit it in memory first. It does not influence whether we use filesort or not. The conclusion is that the names are a bit misleading but once you know what they actually mean, it is rather obivous that SQL_BIG_RESULT takes precedence over SQL_SMALL_RESULT. Better names would probably be "Prefer Filesort over Grouping Tables" and "Try to fit Grouping Tables in Memory".
[8 Dec 2020 17:41]
Paul DuBois
Posted by developer: Based on Martin's explanation, closing as not a bug.