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 2
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.api;
|
||||
|
||||
import io.ebean.meta.QueryPlanRequest;
|
||||
import io.ebeaninternal.server.type.bindcapture.BindCapture;
|
||||
|
||||
class NoopQueryBindCapture implements SpiQueryBindCapture {
|
||||
@@ -16,7 +15,7 @@ class NoopQueryBindCapture implements SpiQueryBindCapture {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collectQueryPlan(QueryPlanRequest request) {
|
||||
public void queryPlanInit(long thresholdMicros) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
package io.ebeaninternal.api;
|
||||
|
||||
import io.ebean.meta.MetaQueryPlan;
|
||||
import io.ebean.meta.QueryPlanRequest;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
class NoopQueryPlanManager implements QueryPlanManager {
|
||||
|
||||
@Override
|
||||
public SpiQueryBindCapture createBindCapture(SpiQueryPlan queryPlan) {
|
||||
return SpiQueryBindCapture.NOOP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetaQueryPlan> collect(QueryPlanRequest request) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package io.ebeaninternal.api;
|
||||
|
||||
import io.ebean.meta.MetaQueryPlan;
|
||||
import io.ebean.meta.QueryPlanRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Manage query plan capture.
|
||||
*/
|
||||
@@ -11,4 +16,9 @@ public interface QueryPlanManager {
|
||||
* Create the bind capture for the given query plan.
|
||||
*/
|
||||
SpiQueryBindCapture createBindCapture(SpiQueryPlan queryPlan);
|
||||
|
||||
/**
|
||||
* Collect the database query plans.
|
||||
*/
|
||||
List<MetaQueryPlan> collect(QueryPlanRequest request);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package io.ebeaninternal.api;
|
||||
|
||||
import io.ebean.meta.MetaQueryPlan;
|
||||
|
||||
/**
|
||||
* Internal database query plan being capture.
|
||||
*/
|
||||
public interface SpiDbQueryPlan extends MetaQueryPlan {
|
||||
|
||||
/**
|
||||
* Extend with queryTimeMicros and captureCount.
|
||||
*/
|
||||
SpiDbQueryPlan with(long queryTimeMicros, long captureCount);
|
||||
|
||||
}
|
||||
@@ -20,12 +20,16 @@ public interface SpiQueryBindCapture {
|
||||
boolean collectFor(long timeMicros);
|
||||
|
||||
/**
|
||||
* Set the bind capture and the related query execution time.
|
||||
* Set the captured bind values that we can use later to collect a query plan.
|
||||
*
|
||||
* @param bindCapture The bind values of the query
|
||||
* @param queryTimeMicros The query execution time
|
||||
* @param startNanos The nanos start of this bind capture
|
||||
*/
|
||||
void setBind(BindCapture bindCapture, long timeMicros, long startNanos);
|
||||
void setBind(BindCapture bindCapture, long queryTimeMicros, long startNanos);
|
||||
|
||||
/**
|
||||
* Collect the query execution plan usually executing the query to do so.
|
||||
* Update the threshold micros triggering the bind capture.
|
||||
*/
|
||||
void collectQueryPlan(QueryPlanRequest request);
|
||||
void queryPlanInit(long thresholdMicros);
|
||||
}
|
||||
|
||||
@@ -31,4 +31,18 @@ public interface SpiQueryPlan {
|
||||
* The related profile location.
|
||||
*/
|
||||
ProfileLocation getProfileLocation();
|
||||
|
||||
/**
|
||||
* Initiate bind capture with the give threshold.
|
||||
*/
|
||||
void queryPlanInit(long thresholdMicros);
|
||||
|
||||
/**
|
||||
* Return as Database query plan.
|
||||
*
|
||||
* @param bind Description of the bind values used
|
||||
* @param planString The raw database query plan
|
||||
*/
|
||||
SpiDbQueryPlan createMeta(String bind, String planString);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user