1. A method for optimizing a search for a query, comprising: providing a subplan for an optimization block in the query; determining a maximum estimated cost for executing an access plan for the subplan using an inexpensive algorithm from a pool of search space generation algorithms; when the maximum estimated cost is greater than a threshold cost for generating the access plan for the subplan, analyzing algebraic properties of a hypergraph to determine complexity of the subplan for the optimization block; identifying characteristics of each algorithm from the pool of search space generation algorithms, wherein each algorithm is configured to generate an associated access plan for the subplan; and selecting an algorithm from the pool of search space generation algorithms based on the complexity of the subplan and characteristics of each algorithm; and when the maximum estimated cost is less than the threshold cost for generating the access plan for executing the subplan, selecting the inexpensive algorithm; and generating the access plan for the subplan using the selected algorithm to optimize the search for the query.