quick icon indicating copy to clipboard operation
quick copied to clipboard

Cache the results of retrieveQualifiedColumns?

Open davidAtInleague opened this issue 3 years ago • 0 comments

we have something like this

component extends=quick {
   function relation() { hasOne(...) }
   function applyGlobalScopes() {
      this.withFoo().withBar().withBaz();
   }
   function scopeWithFoo(qb) { addSubselect("foo", "relation.nestedRelation.property1"); }
   function scopeWithBar(qb) { addSubselect("bar", "relation.nestedRelation.property2"); }
   function scopeWithBaz(qb) { addSubselect("baz" "relation.nestedRelation.property3"); }
}

"nestedRelation" is an entity with 100 properties, which can take about 10ms to run "retrieveQualifiedColumns".

For every instantiation of the HasOne relation, it re-runs "retrieveQualifiedColumns", which scales poorly.

Can the results of retrieveQualifiedColumns be cached? I would expect yes if it only considers non-virtual, lexically declared properties (i.e. those declared like property name='foo' sqltype='varchar' ...;); I have some traces that seem to indicate this is the case, but my visibility into the inner workings is limited and maybe it does, or sometimes can, consider virtual attributes, which may make caching difficult.

If it only considers lexically declared properties, it might be nice to do this at coldbox startup time, maybe configurably. In production cases I wouldn't expect schema to change. In development, well, you'd have to reboot coldbox, which seems reasonable.

davidAtInleague avatar Feb 24 '22 14:02 davidAtInleague