Calculate statement-specific costs
The optimizer compares the cost in time and memory to
perform such tasks as the following:
- Locating an index entry or table row on disk
- Retrieving the entry or row into memory
- Sorting and joining data
- Applying WHERE clause qualifications
- Retrieving rows from a primary table, if the optimizer uses an index
If the query involves a user-defined access method, the database server executes the am_scancost purpose function to request cost information from the access method.
To avoid error messages, the access method can use the am_scancost purpose function to notify the optimizer when it does not support all the requirements specified in a query. If necessary, am_scancost can return a negative cost so that the optimizer excludes this access method from the query plan.