mi_real * am_scancost(MI_AM_TABLE_DESC *tableDesc, MI_AM_QUAL_DESC *qualDesc)
The am_scancost purpose function estimates the cost to fetch and qualify data for the current query. The optimizer relies on the am_scancost return value to evaluate a query path for a scan that involves the access method. This function is not called for indexes on remote tables.
The following types of information influence cost:
To calculate a cost, am_scancost considers the following factors:
Add 1 to the cost for every disk access required to access the data.
Add .15 to the cost for every row accessed in memory.
Compute the cost of retrieving only those table entries that qualify.
To adjust the result of am_scancost, set the am_costfactor purpose value. The database server multiplies the cost that am_scancost returns by the value of am_costfactor, which defaults to 1 if you do not set it. To find out how to set purpose values, refer to SQL Statements for Access Methods.
The optimizer might need a new scan cost for subsequent scans of the same table, for example, because of a join. To execute am_scancost before each rescan, call the mi_qual_setreopt() function. For a list of VTI accessor functions that am_scancost can call to help evaluate cost and the need to reoptimize, refer to Related Topics.
The return value is a pointer to an mi_real data type that contains the cost value.
See the descriptions of: