1. A method for optimizing query processing, the method comprising: storing, at a database system, metadata for an external table; wherein the metadata for the external table defines one or more columns for the external table and how data from an external data source maps to the one or more columns of the external table; receiving, at the database system, a query that requires foreign data from the external data source; in response to receiving the query, determining whether the foreign data currently resides in a cache of the database system; in response to determining that the foreign data does not currently reside in the cache: retrieving the foreign data from the external data source; wherein the external data source has a different structure and format than the database system and the foreign data is stored in a particular format and structure associated with the external data source; mapping, based on the metadata for the external table, the foreign data from the particular format and structure associated with the external data source to a column granule of the external table; and storing the column granule in the cache.