I have a set of tables inherited from the parent table and finally got stuck with the SQL limitation of joining too many tables.
Too many tables; MySQL can only use 61 tables in a join. Stacktrace follows:
java.sql.SQLException: Too many tables; MySQL can only use 61 tables in a join
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3933)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3869)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2524)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2675)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2465)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1915)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2023)
How can I avoid joining the tables while selecting from the parent table? Similar to set lazy: true
for a property, is there any option to load all the associations LAZY by a single configuration?
Class Parent {
long id,
String name
DisplayMode layoutMode
......
static mappings = {
cache: true,
version: true
}
}
Class Child1 extends Parent{
long id,
String prop1
String prop2
......
static mappings = {
cache: true,
version: true
}
}
Class Child2 extends Parent{
long id,
String prop1
String prop2
......
static mappings = {
cache: true,
version: true
}
}
Class Child3 extends Parent{
long id,
String prop1
String prop2
......
static mappings = {
cache: true,
version: true
}
}
There is almost 60+ child tables defined already. This parent class is a Dashboard parent and child are each dashlets and there is more dashlets yet to come.
Any select happening on Parent table joins all the child tables and I need to avoid that.
Grails version: 2.4.3
MySQL : 8