A method for automatically ranking database records by relevance to a
given query. A similarity function is derived from data in the database
and/or queries in a workload. The derrived similarity function is applied
to a given query and records it in the database to rank the records. The
records are returned in a ranked order.