Query selectivity

If your UDR is a Boolean function, it can be used as a filter in a query. The query optimizer uses the selectivity of a query to estimate the number of rows that the query will return. The selectivity is a floating-point value between zero and one that represents the percentage of rows for which the query (and each filter in the query) is expected to return a true value.

For a list of Boolean functions that are useful as query filters, see Boolean functions useful as query filters.

For a Boolean function likely to be used as a query filter, you can use the following routine modifiers to specify a selectivity for the function.
Selectivity Routine modifier
Selectivity is constant for every invocation of the Boolean function. SELCONST = selectivity_value

selectivity_value is a floating-point value between 0 and 1.

Selectivity varies according to some execution conditions. SELFUNC = selectivity_func

selectivity_func is the name of a selectivity function that returns a floating-point value between 0 and 1 to indicate the selectivity of the Boolean function.

When the query optimizer needs to determine the selectivity of the Boolean function, it either uses the constant selectivity value or calls the selectivity function, depending whether the Boolean function was registered with the SELCONST or SELFUNC routine modifier.