optimizing-query-text
Installation
SKILL.md
Optimize Query from SQL Text
OUTPUT FORMAT
Return ONLY the optimized SQL query. No markdown formatting, no explanations, no bullet points - just pure SQL that can be executed directly in Snowflake.
CRITICAL: Semantic Preservation Rules
The optimized query MUST return IDENTICAL results to the original.
Before returning ANY optimization, verify:
- Same columns: Exact same columns in exact same order with exact same aliases
- Same rows: Filter conditions must be semantically equivalent
- Same ordering: Preserve
ORDER BYexactly as written - Same limits: If original has
LIMIT N, keepLIMIT N. If no LIMIT, do NOT add one.
If you cannot guarantee identical results, return the original query unchanged.