Hive optimization skill
Skill reverie2129/hive-optimization-skill-en/skills/hive-optimization-skill
Reviews and optimizes Hive on MapReduce jobs (table design, HQL, JOINs, data skew, MR tuning). Contains 26 citable rules. Use when optimizing HQL, diagnosing slow Hive jobs, handling skew, or designing partitioned/bucketed tables. Always check rules/ before advising and cite rule names.From its SKILL.md
npx -y skills add reverie2129/hive-optimization-skill-en --skill hive-optimization-skillAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as Apache-2.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
9.6 KB, ~2.3k tokens by cl100k_base, as published. Nobody here has run it
Hive Best Practices (MapReduce Job Optimization)
An optimization guide for Hive on MapReduce, covering storage & table design, query optimization, JOIN optimization, data skew, MapReduce parameter tuning, and engine selection. Six categories, 26 rules, ordered by impact on job performance.
Official docs: Apache Hive Wiki
Important: How to Apply This Skill
Before answering any Hive optimization question, follow this priority:
- Check whether a rule in
rules/applies - If a rule applies: apply it and cite it in your response as "Per
rule-name…" - If no rule applies: use general Hive knowledge or consult official documentation
- If uncertain: search for best practices for the current version
- Always cite the source: rule name, "general Hive guidance", or a documentation URL
Why rules come first: Hive on MapReduce has a specific execution model (every MR job spills intermediate results to HDFS, shuffle cost, single-Reducer bottlenecks, data-skew long tails). General database intuition often fails. Rules encode Hive/MR-specific, validated experience.
Review Workflow
Table Design Review (CREATE TABLE)
Read these rule files in order:
rules/storage-file-format.md— use ORC/Parquet columnar storagerules/storage-compression.md— enable compressionrules/storage-partition.md— partition by query filter dimensions (low cardinality)rules/storage-bucketing.md— bucket on JOIN keysrules/storage-small-files.md— avoid small files
Checklist:
- Storage format is ORC/Parquet (not TextFile)
- Compression configured (storage / intermediate / output)
- Partitioned on low-cardinality, high-frequency filter columns (usually
dt); no high-cardinality partition keys - Large-table JOIN scenarios bucketed and sorted on JOIN keys
- Write strategy in place to avoid small files
Query Review (SELECT / Aggregation)
Read these rule files:
rules/query-partition-pruning.md— hit partition pruningrules/query-column-pruning.md— avoid SELECT *rules/query-predicate-pushdown.md— predicate pushdownrules/query-cbo-stats.md— enable CBO + statisticsrules/query-vectorization.md— vectorized executionrules/query-count-distinct.md— rewrite count(distinct)rules/query-order-by.md— ORDER BY / SORT BY choice
Checklist:
- WHERE hits partition pruning (no functions on partition columns)
- Only necessary columns selected; no
SELECT * - Predicates pushable (PPD on; outer-join filters in ON)
- CBO enabled and tables have statistics
- Vectorization enabled for ORC tables
- No single-Reducer bottlenecks (count distinct / ORDER BY rewritten)
JOIN Review
Read these rule files:
rules/join-map-join.md— Map Join for small tablesrules/join-bucket-smb.md— Bucket Map Join / SMB Join for large tablesrules/join-order.md— JOIN order and early filteringrules/join-skew.md— JOIN data skewrules/skew-null.md— NULL join-key skew
Checklist:
- Large JOIN small uses Map Join (
hive.auto.convert.join=true) - Large JOIN large uses bucketing + SMB Join
- Filter before join; largest table last in JOIN sequence
- Hot keys and NULL join-key skew handled
Data Skew Review
Read these rule files:
rules/skew-groupby.md— GROUP BY skewrules/join-skew.md— JOIN skewrules/skew-null.md— NULL skew
Checklist:
- GROUP BY skew: map-side aggregation on;
groupby.skewindatawhen needed - JOIN hot keys handled via skew join or salting
- NULL/default join keys filtered or scattered
Parameter Tuning Review
Read these rule files:
rules/mr-mapper-count.md— Mapper count (split size)rules/mr-reducer-count.md— Reducer countrules/mr-map-aggr.md— map-side aggregationrules/mr-parallel.md— parallel executionrules/mr-speculative.md— speculative executionrules/mr-merge-output.md— output merging
Checklist:
- Reasonable Mapper count (CombineHiveInputFormat for small files)
- Reducers auto-estimated via
bytes.per.reducer, not blindly hard-coded - Map-side aggregation enabled
- Independent stages run in parallel
- Speculative execution correctly toggled for skew / external-table writes
- Output small files merged
Output Format
Organize responses as follows:
## Rules Checked
- `rule-name-1` - compliant / violation found
- `rule-name-2` - compliant / violation found
...
## Findings
### Violations
- **`rule-name`**: problem description
- Current: [current HQL/table design]
- Required: [what should be done]
- Fix: [concrete change with SQL/parameters]
### Compliant
- `rule-name`: brief explanation of why it's correct
## Recommendations
[Prioritized change list, citing rule names]
Rule Categories and Priority
| Priority | Category | Impact | Prefix | Count |
|---|---|---|---|---|
| 1 | Storage format | CRITICAL | storage-file- | 1 |
| 2 | Partition design | CRITICAL | storage-partition | 1 |
| 3 | Partition pruning | CRITICAL | query-partition- | 1 |
| 4 | Map JOIN | CRITICAL | join-map- | 1 |
| 5 | JOIN skew | CRITICAL | join-skew | 1 |
| 6 | Compression / bucketing / small files | HIGH | storage- | 3 |
| 7 | Column pruning / PPD / CBO / vectorization | HIGH | query- | 4 |
| 8 | SMB JOIN | HIGH | join-bucket- | 1 |
| 9 | GROUP BY skew | HIGH | skew-groupby | 1 |
| 10 | Mapper / Reducer / map agg / output merge | HIGH | mr- | 4 |
| 11 | count distinct / sorting / JOIN order | MEDIUM | various | 3 |
| 12 | NULL skew / parallel / speculative | MEDIUM | various | 3 |
| 13 | Dynamic partition / engine choice | MEDIUM | engine- | 2 |
Quick Reference
Storage & Table Design (storage)
storage-file-format— ORC/Parquet columnar storage; no TextFile for large tables [CRITICAL]storage-partition— partition on low-cardinality high-frequency filter columns; no high-cardinality keys [CRITICAL]storage-compression— enable storage / intermediate / output compression (Snappy default)storage-bucketing— bucket on JOIN keys to support Bucket Map / SMB Joinstorage-small-files— write-side merge + read-side CombineHiveInputFormat
Query Optimization (query)
query-partition-pruning— WHERE hits partition pruning; no functions on partition columns [CRITICAL]query-column-pruning— select only necessary columns; avoidSELECT *query-predicate-pushdown— predicate pushdown; outer-join filters in ONquery-cbo-stats— enable CBO and ANALYZE statisticsquery-vectorization— vectorized execution for ORC tablesquery-count-distinct— two-stage rewrite to avoid single Reducerquery-order-by— use ORDER BY sparingly; SORT/DISTRIBUTE/CLUSTER BY as needed
JOIN Optimization (join)
join-map-join— broadcast small tables as Map Join; skip Reduce [CRITICAL]join-skew— handle hot-key skew (skew join / salting) [CRITICAL]join-bucket-smb— Bucket Map / SMB Join for large JOIN largejoin-order— filter first, join later; largest table last
Data Skew (skew)
skew-groupby— map-side aggregation +groupby.skewindatatwo-stageskew-null— filter or salt NULL/default join keys
MapReduce Parameters (mr)
mr-mapper-count— control Mapper count via split size and CombineHiveInputFormatmr-reducer-count— auto-estimate Reducers viabytes.per.reducermr-map-aggr— enable map-side aggregation to reduce Shufflemr-merge-output— merge output small files at job endmr-parallel— parallel execution of independent stagesmr-speculative— manage speculative execution for skew / external-table scenarios
Engine & Advanced (engine)
engine-dynamic-partition— correct dynamic-partition config + DISTRIBUTE BY to control file countengine-consider-tez— evaluate Tez/Spark when MR is the bottleneck
When to Trigger This Skill
Enable when you encounter:
CREATE TABLE/ALTER TABLEstatements- Slow, long-running, or stage-stuck HQL queries
- JOIN optimization (large-table joins, broadcast, bucketing)
- "Job stuck at 99%" / Reduce long tail / data skew
- Too many small files, abnormal Mapper/Reducer counts
- GROUP BY / COUNT(DISTINCT) / ORDER BY performance issues
- Dynamic-partition writes, ETL scheduling optimization
- Considering switching away from MapReduce
Rule File Structure
Each rule file in rules/ contains:
- YAML frontmatter: title, impact level, tags
- Brief explanation: why it matters (impact on MR jobs)
- Bad example: anti-pattern and why it's slow
- Good example: best practice with parameters/SQL
- Supplement: comparison tables, scenarios, official doc links
Full Compilation
For a one-page overview of all rules, read: AGENTS.md (all rules inlined — no need to open individual files).
What ships with it: 28 files
55.6 KB alongside SKILL.md
rules/
- engine-consider-tez.md2.3 KB
- engine-dynamic-partition.md2.1 KB
- join-bucket-smb.md2.4 KB
- join-map-join.md2.4 KB
- join-order.md2.2 KB
- join-skew.md2.9 KB
- mr-map-aggr.md2.0 KB
- mr-mapper-count.md2.0 KB
- mr-merge-output.md2.2 KB
- mr-parallel.md1.8 KB
- mr-reducer-count.md2.0 KB
- mr-speculative.md1.8 KB
- query-cbo-stats.md1.3 KB
- query-column-pruning.md1.4 KB
- query-count-distinct.md2.0 KB
- query-order-by.md1.6 KB
- query-partition-pruning.md1.6 KB
- query-predicate-pushdown.md1.4 KB
- query-vectorization.md1.3 KB
- _sections.md2.6 KB
- skew-groupby.md2.3 KB
- skew-null.md1.9 KB
- storage-bucketing.md2.4 KB
- storage-compression.md2.2 KB
- storage-file-format.md1.9 KB
- storage-partition.md2.5 KB
- storage-small-files.md2.3 KB
- _template.md765 B