GUACAMOLE-1253: Update select all queries to process in batches.

This commit is contained in:
Alex Leitner
2023-03-30 15:01:10 +00:00
committed by Mike Jumper
parent 7e38a089cf
commit 2708a205d3
8 changed files with 143 additions and 15 deletions

View File

@@ -104,6 +104,20 @@ public class MySQLEnvironment extends JDBCEnvironment {
* The default SSL mode for connecting to MySQL servers.
*/
private final MySQLSSLMode DEFAULT_SSL_MODE = MySQLSSLMode.PREFERRED;
/**
* The default maximum number of identifiers/parameters to be included in a
* single batch when executing SQL statements for MySQL and MariaDB.
*
* MySQL and MariaDB impose a limit on the maximum size of a query,
* determined by the max_allowed_packet configuration variable. A value of
* 1000 is chosen to accommodate the max_allowed_packet limit without
* exceeding it.
*
* @see https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_max_allowed_packet
* @see https://mariadb.com/kb/en/server-system-variables/#max_allowed_packet
*/
private static final int DEFAULT_BATCH_SIZE = 1000;
/**
* Constructs a new MySQLEnvironment, providing access to MySQL-specific
@@ -134,6 +148,13 @@ public class MySQLEnvironment extends JDBCEnvironment {
DEFAULT_ABSOLUTE_MAX_CONNECTIONS
);
}
@Override
public int getBatchSize() throws GuacamoleException {
return getProperty(MySQLGuacamoleProperties.MYSQL_BATCH_SIZE,
DEFAULT_BATCH_SIZE
);
}
@Override
public int getDefaultMaxConnections() throws GuacamoleException {

View File

@@ -265,4 +265,16 @@ public class MySQLGuacamoleProperties {
};
/**
* The maximum number of identifiers/parameters to be included in a single batch when
* executing SQL statements.
*/
public static final IntegerGuacamoleProperty MYSQL_BATCH_SIZE =
new IntegerGuacamoleProperty() {
@Override
public String getName() { return "mysql-batch-size"; }
};
}