I'd like to do performance tests of the same SOQL query to check which order of WHERE
and indexes configuration would be the fastest, but database caching makes it hard - after the first SOQL, the next ones are much faster, up to 1/4 of the original time.
I've read on the Salesforce page that direct cache flushing is not possible:
Q: Is there any way to flush the cache when doing your performance testing so your results are not cache biased?
A: Unfortunately not. Queries with selective filters will perform more consistently with less performance variation due to caching, however.
Source: https://help.salesforce.com/s/articleView?id=000330734&type=1
However, the cache size should be finite, so I tried to overwrite the current cache with another, not related query with large output, but the first query still was as fast as before.
Do you know any reliable way to flush the database cache, or maybe there is a different approach for query testing?