New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for QueryResult caching #1251
Conversation
@kghbln Once this is merged lets try to experiment on the sandbox. Probably
I'm not sure how to quantify the impact of having the cache enabled as we should see (or expect) less requests to the DB backend. |
fdc5020
to
ca63570
Compare
After a year this got finally some love! @kghbln Some notes:
Some preliminary comparison on cached/non-cached response times. I'm unable to say how much the QueryResultCache can actually "save" computing or how high the retention rate would be in terms of cache vs. non-cached queries in a production environment.
|
Let's not wait another year! |
Happy testing. |
@kghbln Did we enable this on the sandbox? |
No, if it is not shown on the setup page ... For why: at the time this got merged I switched to 2.4.x and after getting back to normal I had senior moments. However, this is now switched to |
Just pulled some data from the sandbox and we can see that in 48% of the requests we hit the cache (or better avoid computation of a query condition). We'll add more data points on what causes the delete rates but this requires a reset and a new version (that's why it is called transient stats).
|
New stats will include things like (those of
|
Different statistics from the sandbox: I changed (a23b92d) the default cacheLifeTime for embedded queries (those that can be purged automatically by the
|
Most of the job is already done by the
QueryDependencyLinksStore
to track and update query dependencies.To eliminate unnecessary SQL/SPARQL connections
QueryResultCache
ought to cache a subject list returned from theQueryEngine
.We don't cache the string result of a printer == it means we don't interfere with how the printer manipulates the data displayed,
QueryResultCache
as the name suggests caches the return object (akaQueryResult
) from the QueryEngine before it is forwarded to an individual printer.If for some reason
QueryDependencyLinksStore
is not enabled then auto-invalidation of theQueryResultCache
items can not occur and instead (same as of now, meaning manual intervention using the purge button) setting$GLOBALS['smwgQueryResultCacheRefreshOnPurge'] = true;
canbe used so that during an purge action event the cache is invalidated for all queries stored with a corresponding article (aka subject).
Features and limitations
limit=0
,format=debug
, andSpecial:Ask
queries are not cachedredis
is the preferred external StoreEngine in order to avoid issues during serialization as well as in terms of the amount of data to be stored/requested$GLOBALS['smwgQueryResultCacheType']
is set toCACHE_NONE
which means the feature is disabled, choosing an appropriate type is left to a administrator$GLOBALS['smwgQueryResultCacheLifetime'] = 60 * 60 * 24; // a day
declares the lifetime of a cached itemrefs #1035, #1117