org.intermine.sql.query
Class ExplainResult

java.lang.Object
  extended by org.intermine.sql.query.ExplainResult
Direct Known Subclasses:
DummyExplainResult, PostgresExplainResult

public class ExplainResult
extends java.lang.Object

Represents a result from an EXPLAIN request to a database.


Field Summary
protected  long complete
           
protected  long estimatedRows
           
protected  long rows
           
protected  long start
           
protected  long width
           
 
Constructor Summary
ExplainResult()
           
 
Method Summary
 boolean equals(java.lang.Object o)
          
 long getComplete()
          Returns the number of page requests before the query is completed, estimated by the database for this query.
 long getEstimatedRows()
          Returns the best current estimate for the number of rows for this query.
static ExplainResult getInstance(java.sql.PreparedStatement stmt)
          Constructs an instance of ExplainResult given a PreparedStatement object.
static ExplainResult getInstance(Query query, java.sql.Connection database)
          Constructs an instance of ExplainResult for a given Query and database Connection.
static ExplainResult getInstance(java.lang.String query, java.sql.Connection database)
          Constructs an instance of ExplainResult for a given query String and database Connection.
 long getRows()
          Returns the number of rows estimated by the database for this query.
 long getStart()
          Returns the number of page requests before the first row is returned, estimated by the database for this query.
 long getTime()
          Returns an estimate of the time it will take to complete the query.
 long getWidth()
          Returns the width of the data returned by the database for this query.
 int hashCode()
          
 void setEstimatedRows(long estimatedRows)
          Use this to provide the object with a "better" estimate of the number of rows in the results of this Query.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

rows

protected long rows

start

protected long start

complete

protected long complete

width

protected long width

estimatedRows

protected long estimatedRows
Constructor Detail

ExplainResult

public ExplainResult()
Method Detail

getInstance

public static ExplainResult getInstance(java.lang.String query,
                                        java.sql.Connection database)
                                 throws java.sql.SQLException
Constructs an instance of ExplainResult for a given query String and database Connection.

Parameters:
query - the String query to be explained. It need not start with "EXPLAIN"
database - a java.sql.Connection by which to access the database. The particular subclass of ExplainResult returned depends on the type of this Connection
Returns:
an instance of ExplainResult
Throws:
java.sql.SQLException - if the query cannot be explained by that database

getInstance

public static ExplainResult getInstance(Query query,
                                        java.sql.Connection database)
                                 throws java.sql.SQLException
Constructs an instance of ExplainResult for a given Query and database Connection.

Parameters:
query - the org.intermine.sql.query.Query to be explained
database - a java.sql.Connection by which to access the database. The particular subclass of ExplainResult returned depends on the type of this Connection
Returns:
an instance of ExplainResult
Throws:
java.sql.SQLException - if the query cannot be explained by that database

getInstance

public static ExplainResult getInstance(java.sql.PreparedStatement stmt)
                                 throws java.sql.SQLException
Constructs an instance of ExplainResult given a PreparedStatement object. Assumes that sql string already has EXPLAIN at beginning

Parameters:
stmt - the PreparedStatement to be explained
Returns:
an instance of ExplainResult
Throws:
java.sql.SQLException - if the query cannot be explained by that database

getRows

public long getRows()
Returns the number of rows estimated by the database for this query.

Returns:
estimated number of rows

getStart

public long getStart()
Returns the number of page requests before the first row is returned, estimated by the database for this query.

Returns:
estimated number page requests before the first row

getComplete

public long getComplete()
Returns the number of page requests before the query is completed, estimated by the database for this query.

Returns:
estimated number page requests before query completion

getWidth

public long getWidth()
Returns the width of the data returned by the database for this query.

Returns:
width in characters

setEstimatedRows

public void setEstimatedRows(long estimatedRows)
Use this to provide the object with a "better" estimate of the number of rows in the results of this Query.

Parameters:
estimatedRows - the better estimate, in rows

getEstimatedRows

public long getEstimatedRows()
Returns the best current estimate for the number of rows for this query.

Returns:
estimated number of rows

getTime

public long getTime()
Returns an estimate of the time it will take to complete the query. The estimate is based on information from the EXPLAIN database call, and possibly a better estimate of how many rows will be returned.

Returns:
estimate of time in milliseconds

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object