Package io.ebeaninternal.server.query
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 Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DataReader
createDataReader(ResultSet rset)
io.ebeaninternal.server.query.DQueryPlanOutput
createMeta(String bind, String planString)
Return as Database query plan.Class<?>
getBeanType()
The related entity bean typeSet<String>
getDependentTables()
String
getHash()
The hash for the query plan.String
getLabel()
long
getLastQueryTime()
Return the time this query plan was last used.String
getLocation()
String
getName()
The plan name.ProfileLocation
getProfileLocation()
The related profile location.io.ebeaninternal.server.query.CQueryPlanStats.Snapshot
getSnapshot(boolean reset)
Return a copy of the current query statistics.String
getSql()
The SQL for the query plan.boolean
isEmptyStats()
Return true if there are no statistics collected since the last reset.boolean
isRawSql()
void
queryPlanInit(long thresholdMicros)
Initiate bind capture with the give threshold.void
resetStatistics()
Reset the query statistics.String
toString()
-
-
-
Method Detail
-
getBeanType
public Class<?> getBeanType()
Description copied from interface:SpiQueryPlan
The related entity bean type- Specified by:
getBeanType
in interfaceSpiQueryPlan
-
getName
public String getName()
Description copied from interface:SpiQueryPlan
The plan name.- Specified by:
getName
in interfaceSpiQueryPlan
-
getHash
public String getHash()
Description copied from interface:SpiQueryPlan
The hash for the query plan.- Specified by:
getHash
in interfaceSpiQueryPlan
-
getSql
public String getSql()
Description copied from interface:SpiQueryPlan
The SQL for the query plan.- Specified by:
getSql
in interfaceSpiQueryPlan
-
getProfileLocation
public ProfileLocation getProfileLocation()
Description copied from interface:SpiQueryPlan
The related profile location.- Specified by:
getProfileLocation
in interfaceSpiQueryPlan
-
getDependentTables
public Set<String> getDependentTables()
-
getLocation
public String getLocation()
-
queryPlanInit
public void queryPlanInit(long thresholdMicros)
Description copied from interface:SpiQueryPlan
Initiate bind capture with the give threshold.- Specified by:
queryPlanInit
in interfaceSpiQueryPlan
-
createMeta
public io.ebeaninternal.server.query.DQueryPlanOutput createMeta(String bind, String planString)
Description copied from interface:SpiQueryPlan
Return as Database query plan.- Specified by:
createMeta
in interfaceSpiQueryPlan
- Parameters:
bind
- Description of the bind values usedplanString
- The raw database query plan
-
createDataReader
public DataReader createDataReader(ResultSet rset)
-
isRawSql
public boolean isRawSql()
-
resetStatistics
public void resetStatistics()
Reset the query statistics.
-
getSnapshot
public io.ebeaninternal.server.query.CQueryPlanStats.Snapshot getSnapshot(boolean reset)
Return a copy of the current query statistics.
-
getLastQueryTime
public long getLastQueryTime()
Return the time this query plan was last used.
-
isEmptyStats
public boolean isEmptyStats()
Return true if there are no statistics collected since the last reset.
-
-