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.

impactThe 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.
01

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.

02

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.

03

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.

04

Implementation

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.

05

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.

06

Evidence

—Tracker records show the recursive traversal and endpoint work, plus another engineer's larger contribution to the final search issue.
—The recorded query comparison is N×3 sequential calls to one recursive CTE and two batched lookups.
—The feature shipped behind a flag; the legacy path remained when the flag was off.