Why do some queries run faster the second time they are run?
Deephaven uses memoization for many table operations, such as avg_by. Memoization stores previously computed results and reuses them instead of computing them again. When you apply the same operation with the same arguments to the same table again, and the earlier result is still valid and available, Deephaven returns that existing result instead of computing it again.
Are all operations in Deephaven memoized?
Not all operations are memoized. Some operations are excluded for one of two reasons:
- The work hasn't been done to memoize the table operation (yet).
- Memoizing the operation would not be safe. For example,
select,update, andviewcalls that compute formula columns are never memoized, and neither are most formula filters, because a formula can return a different result each time it runs.
Do other factors besides memoization make later runs faster?
Yes. The first run also warms caches and compiles code, and later runs benefit from both:
- Warm filesystem and operating system caches. Data read from disk on the first run stays in memory, so later runs read it from memory instead of from disk.
- Just-in-time (JIT) compilation. The JVM compiles frequently run code to optimized machine code while the first run executes, so later runs use the faster compiled code.
Can memoization be disabled for benchmark testing?
Yes. To disable memoization when benchmarking, set the property QueryTable.memoizeResults to false. See Query table configuration for details.
You can include this setting in your configuration file:
Or pass it as a JVM system property. With Docker, set it in the START_OPTS environment variable:
Note
These FAQ pages contain answers to questions about Deephaven Community Core that our users have asked in our Community Slack. If you have a question that is not in our documentation, join our Community and we'll be happy to help!