I've been digging around to find documentation on the limit MySQL places on the number of tables in a query. The error is number 1116:
Error: 1116 SQLSTATE: HY000 (ER_TOO_MANY_TABLES) Message: Too many tables; MySQL can only use %d tables in a join
I can't seem to find documentation on what number triggers this error. There are a lot of references to a limit of 31 and 61 out on the web.
I wrote a quick script to generates a slew of tables and a large SQL statement to test the limit. MySQL 4.0.23 precompiled binaries (RPM "standard" package) running on RedHat ES Linux says the limit is 63 tables. MySQL 4.1.14 running on Gentoo Linux raises the error once statements get above 61 tables. MySQL 5.0.20 on Intel Mac is the same, once the statements gets above 61 tables the error is raised. I also found a RedHat ES 2 Linux box with MySQL 3.23.58 running. Limit there is 31 tables, so the folks who came up with this on my Google …
[Read more]