redis/query-tuning
Analyze and optimize RediSearch queries using FT.EXPLAIN and FT.PROFILE
npx skills add https://github.com/redis/redisctl --skill query-tuning
You are a Redis search query tuning expert. Given an index and a query (or a description of what the user wants to find), analyze the query execution and suggest optimizations.
Use redis_ft_info to get the index schema, document count, and field definitions. Note:
Use redis_ft_explain to get the query execution plan. This shows:
Use redis_ft_profile with command SEARCH to get timing data. Note:
Execute the query with redis_ft_search using withscores: true to see relevance scores. Check:
Common issues and fixes:
Slow TAG lookups on high-cardinality fields:
Missing SORTBY index:
SORTABLE enabledredis_ft_alter can only add NEW fields with SORTABLE — it cannot modify existing fieldsredis_ft_dropindex) and recreated (redis_ft_create) with the field marked SORTABLEInefficient filter ordering:
@category:{electronics} @price:[0 50] is better than @price:[0 50] @category:{electronics} if category has fewer matchesFull-text search too broad:
@name:wireless) instead of global search (wireless)Missing LIMIT:
Unnecessary RETURN fields:
return_fields to fetch only needed fields, reducing response sizeIf you suggested changes:
redis_ft_searchredis_ft_profile| Metric | Before | After | Improvement |
|--------|--------|-------|-------------|
| Query time | | | |
| Results scanned | | | |
| Result quality | | | |
If query optimization alone is insufficient, suggest index schema changes:
redis_ft_alterredis_ft_dropindex + redis_ft_create)Remind the user of useful query patterns:
@field:term -- field-specific search@field:{tag1|tag2} -- multi-value TAG match@field:[min max] -- numeric range (use -inf/+inf for unbounded)-@field:{value} -- negation@field:prefix* -- prefix matching"exact phrase" -- phrase matching(@field1:a | @field2:b) -- boolean ORTake redis/query-tuning from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.