Skip to content
Back to skills

Spark Performance

ASecurity

Diagnose and fix slow or expensive Spark and Databricks jobs. Use when a Spark job is slow, runs out of memory, shuffles too much, has skewed tasks, when writing a join on large tables, or before running a heavy query on a cluster or SQL warehouse.

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added October 2, 2026
ai-agentspythonsqlperformance

Security analysis

A100/100

Scanned October 2, 2026

npx -y skills add idk-arsh/data-agent-rules --skill spark-performance --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Spark Performance?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Spark Performance
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/idk-arsh-spark-performance/badge)](https://www.skillsdirectory.com/skills/idk-arsh-spark-performance)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: spark-performance
description: Diagnose and fix slow or expensive Spark and Databricks jobs. Use when a Spark job is slow, runs out of memory, shuffles too much, has skewed tasks, when writing a join on large tables, or before running a heavy query on a cluster or SQL warehouse.
---

# Spark performance check

## Read the plan first
```python
df.explain(mode="formatted")
```
Look for: `CartesianProduct` or `BroadcastNestedLoopJoin` (an accidental cross join, so fix the join condition); `PartitionFilters: []` on a partitioned table (no pruning, so add a filter on the partition column); `Exchange` everywhere (heavy shuffles).

## Common fixes
| Symptom | Fix |
|---|---|
| Driver OOM | Remove `.collect()` / `.toPandas()` on large data; aggregate or `.limit()` first |
| Join with one small table (< ~100 MB) | `from pyspark.sql.functions import broadcast`; `big.join(broadcast(small), "key")` |
| A few tasks run far longer (skew) | Keep AQE on (`spark.sql.adaptive.enabled`, default on in Spark 3.2+) and `spark.sql.adaptive.skewJoin.enabled=true`; or salt the hot key |
| Slow Python UDF | Replace with built-in `pyspark.sql.functions`; if unavoidable, use a pandas UDF |
| Reading everything | Select only needed columns; filter on partition or clustering columns early |
| Many small files | Delta: `OPTIMIZE t`; for new tables prefer liquid clustering (`CLUSTER BY (col)`) over hand-tuned partitioning |
| Same DataFrame recomputed | `.cache()` only if reused 2+ times, then `.unpersist()` |

## Cost on Databricks
- Explore on a small or serverless SQL warehouse, not a large all-purpose cluster.
- Stop clusters you started. Set auto-termination on new ones.
- Say which compute you'll use before a heavy job.

## Verify
Compare runtime and rows before and after on the same input. A faster job that returns a different row count is a bug, not an optimization.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.