A query that is run against the shared session cache is known as an in-memory query. Careful configuration of in-memory querying can improve performance.
By default, a query that looks for a single object based on primary key attempts to retrieve the required object from the cache first, and searches the data source only if the object is not in the cache. All other query types search the database first, by default. You can specify whether a given query runs against the in-memory cache, the database, or both.