Does Fauna do any optimizations to reduce any lookup or deserialization overhead for user-defined functions? Does it keep the most used in memory? Thanks.
Fauna’s query coordinator keeps resources in a cache to re-use when possible. However, Fauna is a shared service: the “most used” (in most cases) doesn’t mean “your most used”. As well, queries are distributed in round-robin fashion to an available node in a replica, so the in-memory cache for a particular node very often won’t contain your UDF even when nobody else’s queries intervene.
Where possible, Fauna performs lazy evaluation and applies short-circuit behavior (such as in And
, Or
, and Not
calls.
Beyond that, UDFs have to be fetched from storage (like any other document). Reaching consensus and manipulating storage is going to be a lot more overhead than parsing the UDF and executing it.
2 Likes