When a query is executed for the first time, the results are stored in the cache. Subsequent requests for the same query can then be served from the cache rather than querying the database again. This reduces database load and improves response times.