1. A non-transitory computer program product storing instructions that, when executed by at least one programmable processor, cause the at least one programmable processor to perform operations comprising: receiving a query request comprising a definition of a query of a database persisted in a column-based storage; identifying a pattern in at least part of the query; matching the identified pattern with a set of pre-defined patterns, each of the pre-defined patterns having associated therewith at least one pre-compiled query execution sub-component of a plurality of pre-compiled query execution sub-components retained in a library; selecting, based on the matching of the identified patterns, an optimal sequence for processing a plurality of tables that must be joined to respond to the query that avoids intermediate results and allows for the query to be performed in a single pass of the database, wherein at least one matching pattern other than the selected matched pattern produces intermediate results that requires more than two passes of the database; generating, based on the matching, a plan for executing the query; and executing the query using the generated plan.