optimizaci-n-sql
Diagnose and fix slow queries using EXPLAIN, rewriting joins, adding filters, and DuckDB-specific optimizations
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Diagnose and fix slow queries using EXPLAIN, rewriting joins, adding filters, and DuckDB-specific optimizations
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Sequence cleaning steps in a chain — trim/case/replace, null handling, deduplication, and type casting — in the right order. Use when raw ingested data needs cleaning before joins or aggregation.
Place Assert and Schema Validation nodes as gates that halt a chain when data is wrong, so bad data never reaches the output. Use when the pipeline must guarantee correctness before exporting or loading downstream.
Choose the right sink format, compression, and destination for a chain's output, and decide between exporting a file vs creating a table. Use at the end of a pipeline when deciding how to persist results.
Best practices for loading files into a chain — single file, folder globs, type detection, and union of many files. Use when the pipeline starts from CSV/Parquet/JSON/Excel files or a folder of files.
Decide between Merge (stack rows / UNION) and Join (match on a key) when a chain has multiple inputs, and set keys and join type correctly. Use when a pipeline combines two or more upstream tables.
Descompone un objetivo de procesamiento en un flujo de nodos Chains (source → transform → sink). Use when the user wants to build a data pipeline / chain, or describes an end-to-end "load X, clean it, summarize, export" goal.
| name | Optimización SQL |
| description | Diagnose and fix slow queries using EXPLAIN, rewriting joins, adding filters, and DuckDB-specific optimizations |
| keywords | slow, performance, optimize, timeout, faster, inefficient, lento, optimizar, rendimiento, tarda, demora, optimización, mejorar, query lenta |
| next | data-quality |
Activa cuando una query es lenta, hace timeout, o el usuario pide mejorar el rendimiento de una consulta existente.
Diagnostica como un médico: el plan de ejecución es la radiografía — léelo, forma una hipótesis del cuello de botella, aplica el fix que ataca esa causa, y mide. No apliques optimizaciones a ciegas; cada fix debe responder a algo que viste en el plan.
validate_sql con detailed=true para ver operadores, estimated rows y join strategiesHASH_JOIN con estimated_rows muy alto → problema de joinSEQ_SCAN en tabla grande → falta de particionado o sampleSORT sin LIMIT → ORDER BY sin límiteapprox_count_distinct(col) (~1% error, 10x más rápido)USING SAMPLE 10% para exploración inicialvalidate_sql en la query reescritaexecute_sql y comparar executionTime en el resultadofinal_answer con: causa raíz identificada, reescritura aplicada, mejora de tiempo medidaUSING SAMPLE 10% — muestreo estadístico para exploración rápidaQUALIFY ROW_NUMBER() OVER (...) = 1 — más eficiente que subquery con MIN/MAXapprox_count_distinct(col) — estimación HyperLogLog, ideal para dashboardsCREATE TABLE AS SELECT ... — materializar CTEs que se reutilizan