[Bug]: max_join_size and sql_big_selects do not enforce SELECT row-examination limits
Maintainers usually reply within 1 day
@matrix-meow is already working on this.
Since Nov 26, 2026.
Assessment
This issue has not been assessed yet.
Description
Description
Reproduced on MatrixOne main commit c0cef5c9cce2164fedd201c188bfffe4d2d09a96 (git_version() = c0cef5c) and compared with MySQL 8.0.46.
MatrixOne accepts and reads back max_join_size and sql_big_selects, but does not enforce the SELECT row-examination limit. With max_join_size=1 and sql_big_selects=0, a three-row single-table SELECT, a three-row key JOIN, and a nine-row CROSS JOIN all execute normally. MySQL rejects all three corresponding statements with Error 1104.
This is not limited to JOIN syntax: the basic single-table case also bypasses the guard. A single-table COUNT(*) also executes on MatrixOne; MySQL permits that optimized aggregate too, so the aggregate is documented below as scope information rather than as a compatibility difference.
Minimal reproduction
DROP DATABASE IF EXISTS repro_max_join_size;
CREATE DATABASE repro_max_join_size;
USE repro_max_join_size;
CREATE TABLE t(id INT PRIMARY KEY, v INT);
INSERT INTO t VALUES(1,10),(2,20),(3,30);
SET SESSION sql_big_selects=0;
SET SESSION max_join_size=1;
SELECT @@session.max_join_size, @@session.sql_big_selects;
-- 1, 0
SELECT * FROM t;
-- MatrixOne: returns all three rows
-- MySQL 8.0.46: ERROR 1104 (42000)
SELECT COUNT(*) FROM t;
-- MatrixOne: 3
-- MySQL 8.0.46: 3 (optimized aggregate; not itself a divergence)
SELECT a.id,b.v
FROM t a JOIN t b ON a.id=b.id
ORDER BY a.id;
-- MatrixOne: returns (1,10),(2,20),(3,30)
-- MySQL 8.0.46: ERROR 1104 (42000)
SELECT a.id,b.id
FROM t a CROSS JOIN t b
ORDER BY a.id,b.id;
-- MatrixOne: returns all nine rows
-- MySQL 8.0.46: ERROR 1104 (42000)
SET SESSION sql_big_selects=1;
SELECT a.id,b.v
FROM t a JOIN t b ON a.id=b.id
ORDER BY a.id;
-- control: succeeds
MySQL 8.0.46 produces the following for the single-table statement while the limit is enabled:
ERROR 1104 (42000): The SELECT would examine more than MAX_JOIN_SIZE rows;
check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=#
if the SELECT is okay
Setting sql_big_selects=1 allows the query again, as documented.
Expected behavior
When SQL_BIG_SELECTS=OFF, MatrixOne must reject a SELECT whose estimated row examination exceeds MAX_JOIN_SIZE, using MySQL-compatible Error 1104 semantics. SQL_BIG_SELECTS=ON should bypass this particular limit. These variables must affect admission/planning rather than being writable no-ops.
MySQL documents the interaction here: https://dev.mysql.com/doc/refman/8.0/en/mysql-tips.html#safe-updates
Additional controls
- A key-JOIN restricted to one result row succeeds.
- The three-row key JOIN and nine-row CROSS JOIN both succeed immediately after
sql_big_selectsis set to1. - As a separate session-variable control,
sql_select_limit=2does limit an unqualified three-row SELECT to two rows, and an explicitLIMIT 3overrides it. Thus the result above is specific to the missingmax_join_sizeenforcement.
Duplicate check
Searched max_join_size, sql_big_selects, ER_TOO_BIG_SELECT, and the Error 1104 text in open and closed issues; no existing report of the missing admission check was found.
- Dominant language
- Go
- Stars
- 1.9k
- Forks
- 312
- Avg merge
- 22h 59m
- Merged PRs (30d)
- 736
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from matrixorigin/matrixone
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
matrixorigin/matrixone#33363 ·
Maintainers usually reply within 1 day
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
matrixorigin/matrixone#33362 ·
Maintainers usually reply within 1 day
-
SLEEP rejects NULL and negative durations that MySQL acceptsPossibly taken @XuPeng-SH claimed this 7 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
matrixorigin/matrixone#32653 ·
Maintainers usually reply within 1 day
-
[Bug]: TestChangeWatchProxy loses its first tenant connection during PingContext in Ubuntu CIPossibly taken @XuPeng-SH claimed this today. Openkind/bug needs-triage
matrixorigin/matrixone#33371 · 1 assignee ·
Maintainers usually reply within 1 day
-
[Bug]: TestDaemonClaimSQLRoundTrip exhausts its shared deadline during the stale claim update in Ubuntu CIPossibly taken @XuPeng-SH claimed this today. Openkind/bug needs-triage
matrixorigin/matrixone#33370 · 1 assignee ·
Maintainers usually reply within 1 day
All issues in matrixorigin/matrixone
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
zalando/postgres-operator#3257 ·
Maintainers usually reply within 2 days
-
[inputs.internal] README lists go_version tag on internal_gather instead of internal_agentPossibly taken @cvas22 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 90/100
influxdata/telegraf#20264 ·
Maintainers usually reply within 1 day
-
[Bug] Standalone migration breaks existing Ingress routes using the envoy-http Service port nameOpenaccepted bug wg/enterprise-environment
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vllm-project/semantic-router#7483 · 1 comment ·
Maintainers usually reply within 1 day
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
stacklok/toolhive-catalog#2076 ·
Maintainers usually reply within 1 day