mirror of
https://github.com/Donkie/Spoolman.git
synced 2026-10-22 01:52:17 -05:00
find_by_color loaded every filament as a full ORM object (with its vendor join) into memory and computed delta-E in Python, then the endpoint re-queried the matched ids anyway. The full-catalog ORM load dominated the cost: a color search ran at a flat ~100ms regardless of how few results it returned, ~5-20x slower than an equivalent regular filtered search, and each concurrent request cloned the whole catalog into memory. Scan only id/color_hex/multi_color_hexes and return the matched ids; callers load full rows for just the matches. The matching algorithm is unchanged. Color search now scales with the match count like any other filter: ~5-16x faster here and the concurrency memory spike (+21MB at 8 concurrent) is gone. Drops the "Slow operation!" note from the color_hex query param since it no longer applies. Verified across SQLite/Postgres/MariaDB/CockroachDB (372 integration tests pass on each). Claude-Session: https://claude.ai/code/session_014Cwk5Yyze9yPvkYkUtMAP4