A recent post by Monty on the difficulty of optimizing subselects,
prompted the following idea which may be anything from great to
worthless!
Given a query, reduce it to a canonical form which contains the
essential information needed for deciding how to perform the query. The
canoical form would translate a part like "name=Smith" to "name=", since
a later query with Smith replaced by Jones would presumably process the
query in the same way. (Probably, simple queries should not be looked
for, or entered, in the saved information, where "simple" depends on
whether the saved information is kept in memory on on disk?)
Look up the canonical entry in a history of past queries (hash table
seems plausible). If found, use the information stored for the method
of processing the query. If not found, decide how to optimize the
query, and store relevent information in the history of past queries.
If the space for storing past queries is exhausted, delete an entry
based on LRU or some other method. (I presume the saved information
would include things like the number of entries necessary to prefer
using indexes rather than a sequential search or to prefer searching one
table prior to another.)
Without knowing a lot about how databases are used, I'm guessing that if
this were done for the 1000 last queries one would find the preferred
method for doing the query more often than not.
Regards,
Fred
fkrogh@stripped