Making asset-tree search faster across the API and interface
Browsing a large asset hierarchy meant repeated database queries and slow loading. I contributed a recursive backend traversal that reduced the query pattern from N×3 calls to three, while another engineer completed most of the final search story. The shared feature added contextual search and progressive prefetch; no before-and-after latency was measured.
Context
People configuring inspection routes had to browse large asset hierarchies. The old path made repeated database calls and loaded slowly; it also had no search.
Problem
Search had to return each matching asset with enough of its tree to show where it belonged. Fetching each level separately made the API chatty, while a flat filtered list would lose the hierarchy that helps users recognize an asset.
Decision
I contributed a recursive PostgreSQL query for the backend traversal and batched related data into three queries total instead of N×3 sequential calls. The tree was assembled in the domain layer in O(n). The overall feature crossed the API and UI; another engineer completed most of the final search issue.
04Implementation
The shared feature added contextual search, in-memory caching, and progressive prefetch behind a feature flag. The legacy route stayed available while the new path was rolled out.
Impact
The query count fell from N×3 sequential calls to three for the recursive result and its related data. Search shipped in the route-configuration flow. No before-and-after latency measure is available, and the work was shared with another engineer.