Details
-
Type: Improvement
-
Status: Open
-
Priority: Minor
-
Resolution: Unresolved
-
Affects Version/s: 4.7
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Versioning Impact:Patch (backwards-compatible bug fixes)
-
Documentation Required?:None
-
Funding Source:Needs Funding
Description
This ticket follows on from CRM-17663 where we agreed the caching for CiviCRM dashlets is not optimal and that if we want report results caching it should happen in the reports context somehow.
We had a long discussion on IRC about how it might work - without a firm resolution - the discussion is attached to CRM-17663
To summarise - the key challenge is that if we want to cache less often than per user we need to determine a way to incorporate some representation of the users ACLs into the cache key. We can assume that all contacts with 'view all contacts' can share a cached copy of the report (perhaps making some checks around things like 'view all contributions' as relevant.
Not all reports apply ACLS & those that do generally call buildACLClause - so it may be possible to generate a hash from there. There is some risk reports could do 'something different' and that might need to be fleshed out a bit.
The alternative approach is more like a query level cache - the issue is that many reports generate temp tables - perhaps the tables could be 'kept around for a bit' like export tables, or the results from a sequence of queries could be cached - with the whole sequence comprising the results e.g
$results = Civi::cacheableSql()
->add("SELECT ....")
->add("CREATE TEMP... ")
->add("SELECT ...")
->execute();
I will paste an extract of the longer IRC discussion as a comment