Home | Previous Page | Next Page   Creating User-Defined Routines > Extending Data Types > Optimizing Queries >

Selectivity Functions

The optimizer bases query-cost estimates on the number of rows to be retrieved from each table. In turn, the estimated number of rows is based on the selectivity of each conditional expression that is used within the WHERE clause. A conditional expression that is used to select rows is termed a filter.

The optimizer can use data distributions to calculate selectivities for the filters in a query. However, in the absence of data distributions, the database server calculates selectivities for filters of different types based on table indexes. The following table lists some of the selectivities that the optimizer assigns to filters of different types.

Filter Expression Selectivity (F)
any-col IS NULL F = 1/10
any-col = any-expression F = 1/10
any-col > any-expression F = 1/3
any-col < any-expression F = 1/3
any-col MATCHES any-expression F = 1/5
any-col LIKE any-expression F = 1/5
...

Selectivities calculated using data distributions are even more accurate than the ones that the preceding table shows, as follows:

Query filters can include user-defined functions. You can improve selectivity of filters that include user-defined functions with the following features:

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]