agentleFS
datafusion-contribdatafusion-contrib/datafusion-skills/skills/explain-plan/SKILL.md

explain-plan

Skill14 starsChanged 8 months agoApache-2.0View on GitHub

Visualize and analyze DataFusion query execution plans. Shows logical and physical plans, identifies performance bottlenecks, and suggests optimizations. Supports EXPLAIN and EXPLAIN ANALYZE.

4 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions4 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 4

    1. hass-energy/haeo★ 77same name
    2. jocarrd/crux-agents★ 4same name
    3. rhawk117/cc-terraform-harness★ 1same name
    4. mdaneshjoo/skills★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository6 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 4 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If not found, delegate to /datafusion-skills:install-datafusion.

    line 21
  2. Very specific:

    If --analyze is present → use EXPLAIN ANALYZE (actually runs the query, shows real metrics)

    line 35
  3. Very specific:

    If the input is natural language, generate SQL first (see /datafusion-skills:query for SQL generation guidelines).

    line 40
  4. Distinctive:

    Check if filter pushdown is happening

    line 76
  5. Very specific:

    Look for predicate in TableScan nodes

    line 94
  6. Distinctive:

    Add indexes or sort data

    line 123
  7. Distinctive:

    Use partitioned data layout

    line 126
  8. Distinctive:

    If relevant, suggest DataFusion configuration changes:

    line 130

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

You are helping the user understand and optimize query execution plans in Apache DataFusion.

Input: $@

Step 1 — Check datafusion-cli is installed

command -v datafusion-cli

If not found, delegate to /datafusion-skills:install-datafusion.

Step 2 — Resolve state

STATE_DIR=""
test -f .datafusion-skills/state.sql && STATE_DIR=".datafusion-skills"
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD")"
PROJECT_ID="$(echo "$PROJECT_ROOT" | tr '/' '-')"
test -f "$HOME/.datafusion-skills/$PROJECT_ID/state.sql" && STATE_DIR="$HOME/.datafusion-skills/$PROJECT_ID"

Step 3 — Determine the mode

  • If --analyze is present → use EXPLAIN ANALYZE (actually runs the query, shows real metrics)
  • Otherwise → use EXPLAIN (shows the plan without execution)

Extract the SQL query (remove --analyze flag if present).

If the input is natural language, generate SQL first (see /datafusion-skills:query for SQL generation guidelines).

Step 4 — Run EXPLAIN

Physical plan (default — shows the execution plan as a visual tree):

datafusion-cli ${STATE_DIR:+--file "$STATE_DIR/state.sql"} -c "
EXPLAIN $SQL;
"

Verbose plan (full optimizer trace — initial logical plan, each optimization pass, initial physical plan, final physical plan with stats and schema):

datafusion-cli ${STATE_DIR:+--file "$STATE_DIR/state.sql"} -c "
EXPLAIN VERBOSE $SQL;
"

With actual metrics (if --analyze) (runs the query, reports per-operator row counts, timing, memory, spill stats):

datafusion-cli ${STATE_DIR:+--file "$STATE_DIR/state.sql"} -c "
EXPLAIN ANALYZE $SQL;
"

Step 5 — Analyze the plan

Parse the execution plan output and provide insights:

Key things to look for:

  1. Full table scans → Look for TableScan without pushdown predicates
    • Suggest adding WHERE clauses or partitioning
    • Check if filter pushdown is happening
  2. Sort operations → SortExec or SortPreservingMergeExec
    • Expensive for large datasets
    • Suggest pre-sorting data or using sorted Parquet files
  3. Hash joins vs merge joins → HashJoinExec vs SortMergeJoinExec
    • Hash joins need memory for the build side
    • Suggest which table should be the build side (smaller table)
  4. Repartitioning → RepartitionExec
    • Shows data shuffling between partitions
    • Can be expensive for large datasets
  5. Projection pushdown → Check if only needed columns are read
    • DataFusion should push projections down to the scan
  6. Predicate pushdown → Check if filters are pushed to the scan level
    • Look for predicate in TableScan nodes
  7. Coalesce partitions → CoalescePartitionsExec
    • Merging partitions back to single partition
    • Expected at the top of the plan

For EXPLAIN ANALYZE, additionally check:

  • Row counts at each stage → identify data amplification or reduction
  • Execution time per operator → find the bottleneck
  • Memory usage → identify memory-intensive operations

Step 6 — Present findings

Structure the analysis as:

Query Plan Summary

Brief description of what the plan does.

Plan Visualization

Present the plan as an indented tree (already DataFusion's default output format).

Performance Analysis

  • Bottlenecks: Operations that are likely slowest
  • Optimizations applied: Filter pushdown, projection pushdown, etc.
  • Opportunities: Suggestions for improving performance

Recommendations

Actionable suggestions, such as:

  • Add indexes or sort data
  • Rewrite the query to enable better pushdown
  • Adjust DataFusion configuration options
  • Use partitioned data layout

Step 7 — Suggest configuration tuning

If relevant, suggest DataFusion configuration changes:

-- Increase target partitions for more parallelism
SET datafusion.execution.target_partitions = 8;

-- Increase batch size for throughput
SET datafusion.execution.batch_size = 16384;

-- Enable/disable optimizations
SET datafusion.optimizer.enable_round_robin_repartition = true;

To explore these settings, try /datafusion-skills:datafusion-docs configuration options.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.