
Optimizing ThingsDB: Speeding up with Type Indexes
In the latest release of ThingsDB , we’ve introduced a way to significantly accelerate the type_all() function. By enabling type indexing, you can now loop over all instances of a specific type with near-instant results. The "Ideal" Way: Hierarchical Access In ThingsDB, the preferred pattern for accessing data is through your own code logic. At InfraSonar , for example, we use a hierarchical structure for our Container type. Every container can have children, and we retrieve the entire tree starting from a .root container. new_type ( ' Container ' ); set_type ( ' Container ' , { name : ' str ' , children : ' {Container} ' , get_containers : | this | { // Recursively collect all containers in a set this . children . reduce ( | a , c | a |= c . get_containers (), set ( this )); } }); // Return a set with all containers via the root: . root . get_containers (); The Problem: When type_all() is slow There are scenarios where data isn't easily reachable through a single root, or where you si
Continue reading on Dev.to
Opens in a new tab


