19. A system comprising: a processor and a memory; a communications interface to a multi-tenant database system having a relational data store and a non-relational data store implemented therein; a request processor to receive a request specifying data to be retrieved from the multi-tenant database system; a customer schema processor to retrieve, based on the request, one or more locations of the data to be retrieved; a query layer agent to generate a database query based on the request, wherein the database query specifies a plurality of data elements to be retrieved, the plurality of data elements including one or more data elements residing within the non-relational data store of the multi-tenant database system and one or more other data elements residing within the relational data store of the multi-tenant database system; a query optimizer to optimize the database query to generate an optimized database query having an optimized query syntax that is distinct from a query syntax of the database query; wherein the query layer agent to execute the optimized database query against the multi-tenant database system to retrieve the data; wherein the query optimizer to further: (i) identify a first sub-query to a table within relational data store, the first sub-query corresponding to the first portion of the data to be retrieved, (ii) identify a second sub-query to the non-relational data store; the second sub-query corresponding to the second portion of the data to be retrieved, (iii) replicate the table within the relational data store to the non-relational data store, and (iv) generate the optimized database query with one or more sub-queries to fetch both the first portion of the data to be retrieved and the second portion of the data to be retrieved from the non-relational data store; and wherein the database query comprises a specified order for two or more database join operations in which at least one of the database join operations comprises joining a child table from the non-relational data store with a master table from the relational data store and wherein the query optimizer is to further modify the specified order for the two or more database join operations.
19. A system comprising: a processor and a memory; a communications interface to a multi-tenant database system having a relational data store and a non-relational data store implemented therein; a request processor to receive a request specifying data to be retrieved from the multi-tenant database system; a customer schema processor to retrieve, based on the request, one or more locations of the data to be retrieved; a query layer agent to generate a database query based on the request, wherein the database query specifies a plurality of data elements to be retrieved, the plurality of data elements including one or more data elements residing within the non-relational data store of the multi-tenant database system and one or more other data elements residing within the relational data store of the multi-tenant database system; a query optimizer to optimize the database query to generate an optimized database query having an optimized query syntax that is distinct from a query syntax of the database query; wherein the query layer agent to execute the optimized database query against the multi-tenant database system to retrieve the data; wherein the query optimizer to further: (i) identify a first sub-query to a table within relational data store, the first sub-query corresponding to the first portion of the data to be retrieved, (ii) identify a second sub-query to the non-relational data store; the second sub-query corresponding to the second portion of the data to be retrieved, (iii) replicate the table within the relational data store to the non-relational data store, and (iv) generate the optimized database query with one or more sub-queries to fetch both the first portion of the data to be retrieved and the second portion of the data to be retrieved from the non-relational data store; and wherein the database query comprises a specified order for two or more database join operations in which at least one of the database join operations comprises joining a child table from the non-relational data store with a master table from the relational data store and wherein the query optimizer is to further modify the specified order for the two or more database join operations. 20. The system of claim 19 , wherein the database query comprises a plurality of sub-queries; and wherein the system further comprises a sub-query processor to: analyze each of the plurality of sub-queries based on in-memory cached statistics; identify one of the plurality of sub-queries as a most efficient sub-query based on the in-memory cached statistics, and generate one or more optimized sub-queries to replace a corresponding one or more of the plurality of sub-queries, wherein one of the optimized sub-queries is identified as the most efficient optimized sub-query and specified as a leading query within the optimized database query.