Refactor for query plan capture with initial threshold micros

This commit is contained in:
rob bygrave
2019-12-23 10:28:08 +13:00
parent 71295077a5
commit 6fcac27dfe
25 changed files with 388 additions and 114 deletions
@@ -1,19 +1,25 @@
package io.ebeaninternal.server.query;
import io.ebeaninternal.api.ExtraMetrics;
import io.ebeaninternal.api.SpiQueryPlan;
import io.ebeaninternal.server.type.bindcapture.BindCapture;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import io.ebeaninternal.server.type.bindcapture.BindCapture;
/**
* A QueryPlanLogger that prefixes "EXPLAIN " to the query. This works for Postgres, H2 and MySql.
*/
public class QueryPlanLoggerExplain extends QueryPlanLogger {
public QueryPlanLoggerExplain(ExtraMetrics extraMetrics) {
super(extraMetrics);
}
@Override
public DQueryPlanOutput logQueryPlan(Connection conn, CQueryPlan plan, BindCapture bind) {
public DQueryPlanOutput collect(Connection conn, SpiQueryPlan plan, BindCapture bind) {
try (PreparedStatement explainStmt = conn.prepareStatement("EXPLAIN " + plan.getSql())) {
bind.prepare(explainStmt, conn);