1. A method for optimizing a query for execution against one or more relational databases, the method comprising: receiving a query submitted by a user, the query including a measure expression and a dimensional context within which the measure expression is to be evaluated; generating a first representation of the query, wherein the first representation of the query comprises a table sub-tree associated with the dimensional context and a scalar sub-tree associated with the measure expression; generating a second representation of the query based on the first representation of the query, wherein generating the second representation of the query comprises: transforming the scalar sub-tree into at least a sparse logical operator, and creating an inner join logical operator that performs an inner join between at least a table returned by the sparse logical operator and a table returned by or derived from a table returned by a logical operator built from the table sub-tree; and providing the second representation of the query for application against the one or more relational databases.