The cost you specify for a function must be compatible with the cost that the optimizer calculates for other parts of the SQL statement. The following formula is one method to approximate the costing algorithm that the optimizer uses:
SET EXPLAIN ON;
SELECT count(*) from bigtable;
Time the query.
For information about sqexplain.out, refer to the IBM Informix: Performance Guide.
The cost of executing the function once can be approximated as follows:
((secost/satime)*facost)
Truncate the calculated cost to an integer value.