1. A computer-implemented method for optimizing a database query in a computer system, comprising: using a cost model to generate at least one query execution plan; monitoring, in the computer system, resource usage of one or more resources of the computer system; storing, in the computer system, a condition code representative of the monitored resource usage; modifying, in the computer system, the cost model using the stored condition code by modifying at least one cost associated with at least one of the one or more resources in order to obtain a modified cost model; generating, in the computer system, a query execution plan for at least one database query using the modified cost model, wherein the generating step performs adaptive selection of the query execution plan to alleviate the resource condition in the computer system; and executing, in the computer system, the query execution plan, wherein a resource condition in the computer system results in costs associated with the resource being increased relative to costs of other resources.