mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Refactor for query plan capture with initial threshold micros - part 3
Use QueryPlanInit
This commit is contained in:
@@ -146,7 +146,7 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
this.encryptedProps = sqlTree.getEncryptedProps();
|
||||
this.stats = new CQueryPlanStats(this);
|
||||
this.dependentTables = sqlTree.dependentTables();
|
||||
this.bindCapture = initBindCaptureRaw(sql);
|
||||
this.bindCapture = initBindCaptureRaw(sql, query);
|
||||
this.hash = md5Hash();
|
||||
}
|
||||
|
||||
@@ -164,8 +164,8 @@ public class CQueryPlan implements SpiQueryPlan {
|
||||
return query.getType().isUpdate() ? SpiQueryBindCapture.NOOP : server.createQueryBindCapture(this);
|
||||
}
|
||||
|
||||
private SpiQueryBindCapture initBindCaptureRaw(String sql) {
|
||||
return sql.equals(RESULT_SET_BASED_RAW_SQL) ? SpiQueryBindCapture.NOOP : server.createQueryBindCapture(this);
|
||||
private SpiQueryBindCapture initBindCaptureRaw(String sql, SpiQuery<?> query) {
|
||||
return sql.equals(RESULT_SET_BASED_RAW_SQL) || query.getType().isUpdate() ? SpiQueryBindCapture.NOOP : server.createQueryBindCapture(this);
|
||||
}
|
||||
|
||||
private String location() {
|
||||
|
||||
@@ -61,12 +61,7 @@ public class CQueryPlanManager implements QueryPlanManager {
|
||||
if (plans.isEmpty()) {
|
||||
return emptyList();
|
||||
}
|
||||
long startNanos = System.nanoTime();
|
||||
try {
|
||||
return collectPlans(request);
|
||||
} finally {
|
||||
timeCollection.addSinceNanos(startNanos);
|
||||
}
|
||||
return collectPlans(request);
|
||||
}
|
||||
|
||||
private List<MetaQueryPlan> collectPlans(QueryPlanRequest request) {
|
||||
@@ -76,7 +71,6 @@ public class CQueryPlanManager implements QueryPlanManager {
|
||||
req.nextCapture();
|
||||
}
|
||||
return req.getPlans();
|
||||
|
||||
} catch (SQLException e) {
|
||||
log.error("Error during query plan collection", e);
|
||||
return emptyList();
|
||||
@@ -84,6 +78,11 @@ public class CQueryPlanManager implements QueryPlanManager {
|
||||
}
|
||||
|
||||
public SpiDbQueryPlan collectPlan(Connection connection, SpiQueryPlan queryPlan, BindCapture last) {
|
||||
return planLogger.collectPlan(connection, queryPlan, last);
|
||||
long startNanos = System.nanoTime();
|
||||
try {
|
||||
return planLogger.collectPlan(connection, queryPlan, last);
|
||||
} finally {
|
||||
timeCollection.addSinceNanos(startNanos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user