摘要 |
A database system holds data in the form of a sequence of records, each record comprising one or more fields. The database can be interrogated by a search query, which specifies a particular logical combination of comparisons to be performed on specified fields of each record. Before the search commences, the search query is compiled to produce an optimised sequence of search code. Each comparison operation is assigned a cost, reflecting the cost in time to retrieve the required fields and to perform the comparisons, and is also assigned a probability, indicating the probability that the comparison will produce a true result. Each logical operation in the search query is then processed, to find the order of handling its arguments that gives the minimum expected cost, and the arguments are re-arranged into that order. |