OctoWiki
Memory Appendix

Category In Query

When filtering variants by category, do it in the SQL query (WHERE clause), not in Go code loops

Source memory file: feedback_category_in_query.md · Category: Feedback / working-preference This is a verbatim dump of Claude's persistent memory for the Octopus project. Rendered inside a code block so nothing is altered.

---
name: Category filter in SQL query not code
description: When filtering variants by category, do it in the SQL query (WHERE clause), not in Go code loops
type: feedback
---

Filter variants by category in the SQL query (WHERE clause), not by iterating in Go code. The user was very clear about this.

**Why:** Performance — don't fetch all variants from the DB just to filter them in code. Push filtering down to the database.

**How to apply:** When adding optional filters to repository methods, add them as SQL WHERE conditions, not as post-query Go loops.