mirror of
https://github.com/google/nomulus
synced 2026-09-29 11:15:45 +00:00
Add a hibernate.default_batch_fetch_size value of 50 (#3232)
This basically controls the number of child entities that will be batch-loaded when we bulk-load multiple root entities. It will be useful for situations like RDE where we load a bunch of domains, because it means we'll batch-load the child entities like nsHosts and gracePeriods.
This commit is contained in:
@@ -1825,6 +1825,18 @@ public final class RegistryConfig {
|
|||||||
return CONFIG_SETTINGS.get().hibernate.jdbcFetchSize;
|
return CONFIG_SETTINGS.get().hibernate.jdbcFetchSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Hibernate default batch fetch size ({@code hibernate.default_batch_fetch_size}).
|
||||||
|
*
|
||||||
|
* <p>This controls the maximum number of uninitialized child entities or collection proxies that
|
||||||
|
* Hibernate will batch together into a single {@code SELECT ... WHERE id IN (...)} query when
|
||||||
|
* loading / initializing child entities in the persistence context. This is not the standard
|
||||||
|
* "batch size" used when loading root entities in batches.
|
||||||
|
*/
|
||||||
|
public static int getHibernateDefaultBatchFetchSize() {
|
||||||
|
return CONFIG_SETTINGS.get().hibernate.defaultBatchFetchSize;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the roid suffix to be used for the roids of all hosts. */
|
/** Returns the roid suffix to be used for the roids of all hosts. */
|
||||||
public static String getHostRoidSuffix() {
|
public static String getHostRoidSuffix() {
|
||||||
return CONFIG_SETTINGS.get().registryPolicy.contactAndHostRoidSuffix;
|
return CONFIG_SETTINGS.get().registryPolicy.contactAndHostRoidSuffix;
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ public class RegistryConfigSettings {
|
|||||||
public String hikariIdleTimeout;
|
public String hikariIdleTimeout;
|
||||||
public int jdbcBatchSize;
|
public int jdbcBatchSize;
|
||||||
public String jdbcFetchSize;
|
public String jdbcFetchSize;
|
||||||
|
public int defaultBatchFetchSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Configuration for Cloud SQL. */
|
/** Configuration for Cloud SQL. */
|
||||||
|
|||||||
@@ -247,6 +247,12 @@ hibernate:
|
|||||||
# database cursor. Here we set a small default geared toward Nomulus server
|
# database cursor. Here we set a small default geared toward Nomulus server
|
||||||
# transactions. Large queries can override the defaults on a per-query basis.
|
# transactions. Large queries can override the defaults on a per-query basis.
|
||||||
jdbcFetchSize: 40
|
jdbcFetchSize: 40
|
||||||
|
# The default batch fetch size is the maximum number of uninitialized child
|
||||||
|
# entities or collection proxies that Hibernate will load / initialize in a
|
||||||
|
# single batched SELECT query using an IN clause. This is not the same as the
|
||||||
|
# JDBC batch size, which controls batched insertions / updates of root
|
||||||
|
# entities.
|
||||||
|
defaultBatchFetchSize: 50
|
||||||
|
|
||||||
cloudSql:
|
cloudSql:
|
||||||
# jdbc url for the Cloud SQL database.
|
# jdbc url for the Cloud SQL database.
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package google.registry.persistence;
|
|||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||||
import static google.registry.config.RegistryConfig.getHibernateConnectionIsolation;
|
import static google.registry.config.RegistryConfig.getHibernateConnectionIsolation;
|
||||||
|
import static google.registry.config.RegistryConfig.getHibernateDefaultBatchFetchSize;
|
||||||
import static google.registry.config.RegistryConfig.getHibernateHikariConnectionTimeout;
|
import static google.registry.config.RegistryConfig.getHibernateHikariConnectionTimeout;
|
||||||
import static google.registry.config.RegistryConfig.getHibernateHikariIdleTimeout;
|
import static google.registry.config.RegistryConfig.getHibernateHikariIdleTimeout;
|
||||||
import static google.registry.config.RegistryConfig.getHibernateHikariMaximumPoolSize;
|
import static google.registry.config.RegistryConfig.getHibernateHikariMaximumPoolSize;
|
||||||
@@ -84,6 +85,7 @@ public abstract class PersistenceModule {
|
|||||||
|
|
||||||
public static final String JDBC_BATCH_SIZE = "hibernate.jdbc.batch_size";
|
public static final String JDBC_BATCH_SIZE = "hibernate.jdbc.batch_size";
|
||||||
public static final String JDBC_FETCH_SIZE = "hibernate.jdbc.fetch_size";
|
public static final String JDBC_FETCH_SIZE = "hibernate.jdbc.fetch_size";
|
||||||
|
public static final String DEFAULT_BATCH_FETCH_SIZE = "hibernate.default_batch_fetch_size";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@Provides
|
@Provides
|
||||||
@@ -113,6 +115,7 @@ public abstract class PersistenceModule {
|
|||||||
properties.put(Environment.DIALECT, NomulusPostgreSQLDialect.class.getName());
|
properties.put(Environment.DIALECT, NomulusPostgreSQLDialect.class.getName());
|
||||||
properties.put(JDBC_BATCH_SIZE, Integer.toString(getHibernateJdbcBatchSize()));
|
properties.put(JDBC_BATCH_SIZE, Integer.toString(getHibernateJdbcBatchSize()));
|
||||||
properties.put(JDBC_FETCH_SIZE, getHibernateJdbcFetchSize());
|
properties.put(JDBC_FETCH_SIZE, getHibernateJdbcFetchSize());
|
||||||
|
properties.put(DEFAULT_BATCH_FETCH_SIZE, Integer.toString(getHibernateDefaultBatchFetchSize()));
|
||||||
return properties.build();
|
return properties.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,11 @@
|
|||||||
package google.registry.persistence;
|
package google.registry.persistence;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static google.registry.persistence.PersistenceModule.DEFAULT_BATCH_FETCH_SIZE;
|
||||||
|
import static google.registry.persistence.PersistenceModule.JDBC_BATCH_SIZE;
|
||||||
|
import static google.registry.persistence.PersistenceModule.JDBC_FETCH_SIZE;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
import dagger.Component;
|
import dagger.Component;
|
||||||
import google.registry.config.CredentialModule;
|
import google.registry.config.CredentialModule;
|
||||||
import google.registry.config.RegistryConfig.Config;
|
import google.registry.config.RegistryConfig.Config;
|
||||||
@@ -77,6 +81,14 @@ class PersistenceModuleTest {
|
|||||||
.isEqualTo(TransactionIsolationLevel.TRANSACTION_SERIALIZABLE.name());
|
.isEqualTo(TransactionIsolationLevel.TRANSACTION_SERIALIZABLE.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void batchAndFetchConfigs() {
|
||||||
|
ImmutableMap<String, String> configs = PersistenceModule.provideDefaultDatabaseConfigs();
|
||||||
|
assertThat(configs.get(JDBC_BATCH_SIZE)).isEqualTo("50");
|
||||||
|
assertThat(configs.get(JDBC_FETCH_SIZE)).isEqualTo("40");
|
||||||
|
assertThat(configs.get(DEFAULT_BATCH_FETCH_SIZE)).isEqualTo("50");
|
||||||
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Component(
|
@Component(
|
||||||
modules = {
|
modules = {
|
||||||
|
|||||||
Reference in New Issue
Block a user