3 ms·
If you can separate call sites somehow, can't you just lazily fetch attributes as required and also remember which attributes were needed for next time? Ie. tea
by FeepingCreature 7y ago
If you can separate call sites somehow, can't you just lazily fetch attributes as required and also remember which attributes were needed for next time? Ie. teach the ActiveRecord library to "learn" its usecase automatically, while appearing trivial to the user.
A similar pattern could be done for on-demand joins, though you might need macro magic (or a dynamic language that lets you, say, subtype 'string') to derive joins from attribute values. For instance, if you have a sufficiently advanced typesystem, you may return instead of a string something like a `SqlSourcedType(string, "tablename", "attributename", originalCallSiteId)` that acts interchangeable with a string. Then later on when passing such a type to a load on another table, the framework would know that you were using a join idiom, and could load the joined tables directly in the first query the next time around. Basically JIT SQL.