Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.iapi.store.access
Interface StoreCostController  view StoreCostController download StoreCostController.java

All Superinterfaces:
RowCountable

public interface StoreCostController
extends RowCountable

The StoreCostController interface provides methods that an access client (most likely the system optimizer) can use to get store's estimated cost of various operations on the conglomerate the StoreCostController was opened for.

It is likely that the implementation of StoreCostController will open the conglomerate and will leave the conglomerate open until the StoreCostController is closed. This represents a significant amount of work, so the caller if possible should attempt to open the StoreCostController once per unit of work and rather than close and reopen the controller. For instance if the optimizer needs to cost 2 different scans against a single conglomerate, it should use one instance of the StoreCostController.

The locking behavior of the implementation of a StoreCostController is undefined, it may or may not get locks on the underlying conglomerate. It may or may not hold locks until end of transaction. An optimal implementation will not get any locks on the underlying conglomerate, thus allowing concurrent access to the table by a executing query while another query is optimizing.


Field Summary
static double BASE_CACHED_ROW_FETCH_COST
           
static double BASE_GROUPSCAN_ROW_COST
           
static double BASE_HASHSCAN_ROW_FETCH_COST
           
static double BASE_NONGROUPSCAN_ROW_FETCH_COST
           
static double BASE_ROW_PER_BYTECOST
           
static double BASE_UNCACHED_ROW_FETCH_COST
           
static int STORECOST_CLUSTERED
          Indicates that access to the page necessary to fulfill the fetch request is likely to be a page "recently" used.
static int STORECOST_SCAN_NORMAL
          Used for the scan_type parameter to the getScanCost() routine.
static int STORECOST_SCAN_SET
          Used for the scan_type parameter to the getScanCost() routine.
 
Method Summary
 void close()
          Close the controller.
 double getFetchFromFullKeyCost(org.apache.derby.iapi.services.io.FormatableBitSet validColumns, int access_type)
          Return the cost of exact key lookup.
 double getFetchFromRowLocationCost(org.apache.derby.iapi.services.io.FormatableBitSet validColumns, int access_type)
          Return the cost of calling ConglomerateController.fetch().
 void getScanCost(int scan_type, long row_count, int group_size, boolean forUpdate, org.apache.derby.iapi.services.io.FormatableBitSet scanColumnList, org.apache.derby.iapi.types.DataValueDescriptor[] template, org.apache.derby.iapi.types.DataValueDescriptor[] startKeyValue, int startSearchOperator, org.apache.derby.iapi.types.DataValueDescriptor[] stopKeyValue, int stopSearchOperator, boolean reopen_scan, int access_type, StoreCostResult cost_result)
          Calculate the cost of a scan.
 org.apache.derby.iapi.types.RowLocation newRowLocationTemplate()
          Return an "empty" row location object of the correct type.
 
Methods inherited from interface org.apache.derby.iapi.store.access.RowCountable
getEstimatedRowCount, setEstimatedRowCount
 

Field Detail

BASE_CACHED_ROW_FETCH_COST

public static final double BASE_CACHED_ROW_FETCH_COST
See Also:
Constant Field Values

BASE_UNCACHED_ROW_FETCH_COST

public static final double BASE_UNCACHED_ROW_FETCH_COST
See Also:
Constant Field Values

BASE_GROUPSCAN_ROW_COST

public static final double BASE_GROUPSCAN_ROW_COST
See Also:
Constant Field Values

BASE_NONGROUPSCAN_ROW_FETCH_COST

public static final double BASE_NONGROUPSCAN_ROW_FETCH_COST
See Also:
Constant Field Values

BASE_HASHSCAN_ROW_FETCH_COST

public static final double BASE_HASHSCAN_ROW_FETCH_COST
See Also:
Constant Field Values

BASE_ROW_PER_BYTECOST

public static final double BASE_ROW_PER_BYTECOST
See Also:
Constant Field Values

STORECOST_CLUSTERED

public static final int STORECOST_CLUSTERED
Indicates that access to the page necessary to fulfill the fetch request is likely to be a page "recently" used. See getFetchFromFullKeyCost() and getScanCost().

See Also:
Constant Field Values

STORECOST_SCAN_SET

public static final int STORECOST_SCAN_SET
Used for the scan_type parameter to the getScanCost() routine. STORECOST_SCAN_NORMAL indicates that the scan will use the standard next/fetch, where each fetch can retrieve 1 or many rows (if fetchNextGroup() interface is used).

See Also:
Constant Field Values

STORECOST_SCAN_NORMAL

public static final int STORECOST_SCAN_NORMAL
Used for the scan_type parameter to the getScanCost() routine. STORECOST_SCAN_SET - The entire result set will be retrieved using the the fetchSet() interface.

See Also:
Constant Field Values
Method Detail

close

public void close()
           throws org.apache.derby.iapi.error.StandardException
Close the controller.

Close the open controller. This method always succeeds, and never throws any exceptions. Callers must not use the StoreCostController Cost controller after closing it; they are strongly advised to clear out the scan controller reference after closing.


getFetchFromRowLocationCost

public double getFetchFromRowLocationCost(org.apache.derby.iapi.services.io.FormatableBitSet validColumns,
                                          int access_type)
                                   throws org.apache.derby.iapi.error.StandardException
Return the cost of calling ConglomerateController.fetch().

Return the estimated cost of calling ConglomerateController.fetch() on the current conglomerate. This gives the cost of finding a record in the conglomerate given the exact RowLocation of the record in question.

The validColumns parameter describe what kind of row is being fetched, ie. it may be cheaper to fetch a partial row than a complete row.


getFetchFromFullKeyCost

public double getFetchFromFullKeyCost(org.apache.derby.iapi.services.io.FormatableBitSet validColumns,
                                      int access_type)
                               throws org.apache.derby.iapi.error.StandardException
Return the cost of exact key lookup.

Return the estimated cost of calling ScanController.fetch() on the current conglomerate, with start and stop positions set such that an exact match is expected.

This call returns the cost of a fetchNext() performed on a scan which has been positioned with a start position which specifies exact match on all keys in the row.

Example:

In the case of a btree this call can be used to determine the cost of doing an exact probe into btree, giving all key columns. This cost can be used if the client knows it will be doing an exact key probe but does not have the key's at optimize time to use to make a call to getScanCost()


getScanCost

public void getScanCost(int scan_type,
                        long row_count,
                        int group_size,
                        boolean forUpdate,
                        org.apache.derby.iapi.services.io.FormatableBitSet scanColumnList,
                        org.apache.derby.iapi.types.DataValueDescriptor[] template,
                        org.apache.derby.iapi.types.DataValueDescriptor[] startKeyValue,
                        int startSearchOperator,
                        org.apache.derby.iapi.types.DataValueDescriptor[] stopKeyValue,
                        int stopSearchOperator,
                        boolean reopen_scan,
                        int access_type,
                        StoreCostResult cost_result)
                 throws org.apache.derby.iapi.error.StandardException
Calculate the cost of a scan.

Cause this object to calculate the cost of performing the described scan. The interface is setup such that first a call is made to calcualteScanCost(), and then subsequent calls to accessor routines are made to get various pieces of information about the cost of the scan.

For the purposes of costing this routine is going to assume that a page will remain in cache between the time one next()/fetchNext() call and a subsequent next()/fetchNext() call is made within a scan.

The result of costing the scan is placed in the "cost_result". The cost of the scan is stored by calling cost_result.setEstimatedCost(cost). The estimated row count is stored by calling cost_result.setEstimatedRowCount(row_count).

The estimated cost of the scan assumes the caller will execute a fetchNext() loop for every row that qualifies between start and stop position. Note that this cost is different than execution a next(),fetch() loop; or if the scan is going to be terminated by client prior to reaching the stop condition.

The estimated number of rows returned from the scan assumes the caller will execute a fetchNext() loop for every row that qualifies between start and stop position.


newRowLocationTemplate

public org.apache.derby.iapi.types.RowLocation newRowLocationTemplate()
                                                               throws org.apache.derby.iapi.error.StandardException
Return an "empty" row location object of the correct type.