views:

77

answers:

1

I know N/Hibernate uses a cache to satisfy queries that it has seen before, and that is called a query cache. However, can it satisfy a subset of that query? I'd imagine not since I'd guess that the general problem of figuring that out is undecidable.

Are there any strategies for doing this, though? Say I have a query for all widgets which cost less than $20. Later, I have a query which is for all widgets under $10. Obviously the second query results would be cached already (assuming no evictions, etc.), so I'd like to just reevaluate the predicate against the cached query predicate to determine if it "contains" it. Are there some practical strategies for doing this?

A: 

Is it quite common for in memory filtering to be used on cached query results, using LINQ for example.

Mitch Wheat
But how do you know the query matches the in memory results, that is, that the results of a previous query cover the query in question? If a query like "Price < 20 AND Color = 'Red'" gets cached, it isn't satisfied by just filtering for "Price < 20 OR Color = 'Red'".
codekaizen
You would usually cache the entire set (where it makes sesne in terms of size)
Mitch Wheat
Right - and that doesn't quite work out for large datasets.
codekaizen
what do you call large? I would expect most reference data to fit in memory
Mitch Wheat