[jOOQ/jOOQ#10048] Add logging to BatchCRUD when the number of generated SQL queries is too high
This commit is contained in:
parent
df155878e5
commit
0b3e93bba2
@ -53,8 +53,9 @@ import org.reactivestreams.Subscriber;
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
abstract class AbstractBatch implements Batch {
|
||||
final Configuration configuration;
|
||||
final DSLContext dsl;
|
||||
|
||||
final Configuration configuration;
|
||||
final DSLContext dsl;
|
||||
|
||||
AbstractBatch(Configuration configuration) {
|
||||
this.configuration = configuration;
|
||||
|
||||
@ -54,14 +54,16 @@ import org.jooq.TableRecord;
|
||||
import org.jooq.UpdatableRecord;
|
||||
import org.jooq.exception.ControlFlowSignal;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
import org.jooq.tools.JooqLogger;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class BatchCRUD extends AbstractBatch {
|
||||
|
||||
private final TableRecord<?>[] records;
|
||||
private final Action action;
|
||||
private static final JooqLogger log = JooqLogger.getLogger(BatchCRUD.class);
|
||||
private final TableRecord<?>[] records;
|
||||
private final Action action;
|
||||
|
||||
BatchCRUD(Configuration configuration, Action action, TableRecord<?>[] records) {
|
||||
super(configuration);
|
||||
@ -119,6 +121,9 @@ final class BatchCRUD extends AbstractBatch {
|
||||
}
|
||||
}
|
||||
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("Batch " + action + " of " + records.length + " records using " + queries.size() + " distinct queries (lower is better) with an average number of bind variable sets of " + queries.values().stream().mapToInt(List::size).average().orElse(0.0) + " (higher is better)");
|
||||
|
||||
// Execute one batch statement for each identical SQL statement. Every
|
||||
// SQL statement may have several queries with different bind values.
|
||||
// The order is preserved as much as possible
|
||||
|
||||
@ -58,7 +58,7 @@ import io.r2dbc.spi.ConnectionFactory;
|
||||
*/
|
||||
final class BatchMultiple extends AbstractBatch {
|
||||
|
||||
final Query[] queries;
|
||||
final Query[] queries;
|
||||
|
||||
public BatchMultiple(Configuration configuration, Query... queries) {
|
||||
super(configuration);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user