I have a table that contains, possibly, from 10 to 100 thousand rows, and I need different sets of up to 1 or 2 thousand rows, but often they are much smaller. I want these queries to be as fast as possible, and I would like to know which approach is usually smarter:
- Always query exactly the rows I need with the WHERE clause, which is different all the time.
- Download the entire table into the in-memory cache inside my application and search there, regularly synchronizing the cache
- Always query the entire table (without the WHERE clause), allow the SQL server to process the cache (it is always the same query so that it can cache the result) and filter the output as necessary
I would like to be an agnostic of a certain DB mechanism at the moment.
source
share