Class CQueryPlan

java.lang.Object
io.ebeaninternal.server.query.CQueryPlan
All Implemented Interfaces:
SpiQueryPlan

public class CQueryPlan extends Object implements SpiQueryPlan
Represents a query for a given SQL statement.

This can be executed multiple times with different bind parameters.

That is, the sql including the where clause, order by clause etc must be exactly the same to share the same query plan with the only difference being bind values.

This is useful in that is common in OLTP type applications that the same query will be executed quite a lot just with different bind values. With this query plan we can bypass some of the query statement generation (for performance) and collect statistics on the number and average execution times. This is turn can be used to identify queries that could be looked at for performance tuning.

  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • beanType

      public final Class<?> beanType()
      Description copied from interface: SpiQueryPlan
      The related entity bean type
      Specified by:
      beanType in interface SpiQueryPlan
    • name

      public final String name()
      Description copied from interface: SpiQueryPlan
      The plan name.
      Specified by:
      name in interface SpiQueryPlan
    • hash

      public final String hash()
      Description copied from interface: SpiQueryPlan
      The hash of the sql.
      Specified by:
      hash in interface SpiQueryPlan
    • sql

      public final String sql()
      Description copied from interface: SpiQueryPlan
      The SQL for the query plan.
      Specified by:
      sql in interface SpiQueryPlan
    • profileLocation

      public final ProfileLocation profileLocation()
      Description copied from interface: SpiQueryPlan
      The related profile location.
      Specified by:
      profileLocation in interface SpiQueryPlan
    • label

      public final String label()
    • dependentTables

      public final Set<String> dependentTables()
    • location

      public final String location()
    • queryPlanInit

      public final void queryPlanInit(long thresholdMicros)
      Description copied from interface: SpiQueryPlan
      Initiate bind capture with the give threshold.
      Specified by:
      queryPlanInit in interface SpiQueryPlan
    • createMeta

      public final io.ebeaninternal.server.query.DQueryPlanOutput createMeta(String bind, String planString)
      Description copied from interface: SpiQueryPlan
      Return as Database query plan.
      Specified by:
      createMeta in interface SpiQueryPlan
      Parameters:
      bind - Description of the bind values used
      planString - The raw database query plan
    • createDataReader

      public DataReader createDataReader(boolean unmodifiable, ResultSet rset)
    • isRawSql

      public final boolean isRawSql()
    • resetStatistics

      public final void resetStatistics()
      Reset the query statistics.
    • visit

      public final io.ebeaninternal.server.query.CQueryPlanStats.Snapshot visit(MetricVisitor visitor)
      Return a copy of the current query statistics.
    • lastQueryTime

      public final long lastQueryTime()
      Return the time this query plan was last used.
    • isEmptyStats

      public final boolean isEmptyStats()
      Return true if there are no statistics collected since the last reset.