1. A method of query optimization, comprising: comparing a complexity measure of a client query received from a client application to a predetermined threshold, the client query received before the client query reaches a server application on a server, wherein the predetermined threshold is determined based on query execution data collected from at least one previous query; generating an optimized query by modifying the client query to reduce the complexity measure of the client query if the complexity measure of the client query exceeds the predetermined threshold, wherein an expected result set size of the optimized query is greater than an expected result set size of the client query; submitting the optimized query to the server application on the server; selecting a post-processing routine to be applied to a result set of the optimized query to have a filtered result set; and returning the filtered set to the client application.