Files
life-echo/api/.agents/skills/redis-development/rules/rqe-query-optimization.md
Sully 53e0065e3e refactor(api): TOML 配置 SSOT、统一错误契约、Auth/事务加固与可观测性 (#33)
配置 SSOT(TOML + .env)
统一错误契约
Auth 与事务边界
Redis / Celery 可靠性:业务 Redis(DB/0)与 Celery broker/backend(DB/1)显式拆分;连接池、sync client
可观测性(OpenTelemetry + LGTM)
2026-05-22 13:44:50 +08:00

1.2 KiB

title, impact, impactDescription, tags, description, alwaysApply
title impact impactDescription tags description alwaysApply
Write Efficient Queries HIGH Proper filtering reduces query time by orders of magnitude rqe, ft.search, query, performance, filters Write Efficient Queries true

Write Efficient Queries

Be specific and use filters to reduce the result set early.

Correct: Use specific filters and limit results.

# Good: Specific query with filters
FT.SEARCH idx:products "@category:{electronics} @price:[100 500]"
    LIMIT 0 20
    RETURN 3 name price category

# Good: Use SORTBY and LIMIT
FT.SEARCH idx:products "@name:laptop"
    SORTBY price ASC
    LIMIT 0 10

Incorrect: Broad queries returning large result sets.

# Bad: Wildcard prefix scans entire index
FT.SEARCH idx:products "*" LIMIT 0 10000

# Bad: Loading all fields from source document
FT.AGGREGATE idx:products "*" LOAD *

Performance tips:

  • Add SORTABLE to fields used in SORTBY
  • Use TAG SORTABLE UNF for best performance on tag fields
  • Use NOSTEM if you don't need stemming
  • Profile queries with FT.PROFILE
FT.PROFILE idx:products SEARCH QUERY "@category:{electronics}"

Reference: Redis Search Query Syntax