agentsclimarketplace

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

Install
npx -y skills add reverie2129/hive-optimization-skill-en --skill hive-optimization-skill

Assembled 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:

  1. Check whether a rule in rules/ applies
  2. If a rule applies: apply it and cite it in your response as "Per rule-name…"
  3. If no rule applies: use general Hive knowledge or consult official documentation
  4. If uncertain: search for best practices for the current version
  5. 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:

  1. rules/storage-file-format.md — use ORC/Parquet columnar storage
  2. rules/storage-compression.md — enable compression
  3. rules/storage-partition.md — partition by query filter dimensions (low cardinality)
  4. rules/storage-bucketing.md — bucket on JOIN keys
  5. rules/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:

  1. rules/query-partition-pruning.md — hit partition pruning
  2. rules/query-column-pruning.md — avoid SELECT *
  3. rules/query-predicate-pushdown.md — predicate pushdown
  4. rules/query-cbo-stats.md — enable CBO + statistics
  5. rules/query-vectorization.md — vectorized execution
  6. rules/query-count-distinct.md — rewrite count(distinct)
  7. 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:

  1. rules/join-map-join.md — Map Join for small tables
  2. rules/join-bucket-smb.md — Bucket Map Join / SMB Join for large tables
  3. rules/join-order.md — JOIN order and early filtering
  4. rules/join-skew.md — JOIN data skew
  5. rules/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:

  1. rules/skew-groupby.md — GROUP BY skew
  2. rules/join-skew.md — JOIN skew
  3. rules/skew-null.md — NULL skew

Checklist:

  • GROUP BY skew: map-side aggregation on; groupby.skewindata when needed
  • JOIN hot keys handled via skew join or salting
  • NULL/default join keys filtered or scattered

Parameter Tuning Review

Read these rule files:

  1. rules/mr-mapper-count.md — Mapper count (split size)
  2. rules/mr-reducer-count.md — Reducer count
  3. rules/mr-map-aggr.md — map-side aggregation
  4. rules/mr-parallel.md — parallel execution
  5. rules/mr-speculative.md — speculative execution
  6. rules/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

PriorityCategoryImpactPrefixCount
1Storage formatCRITICALstorage-file-1
2Partition designCRITICALstorage-partition1
3Partition pruningCRITICALquery-partition-1
4Map JOINCRITICALjoin-map-1
5JOIN skewCRITICALjoin-skew1
6Compression / bucketing / small filesHIGHstorage-3
7Column pruning / PPD / CBO / vectorizationHIGHquery-4
8SMB JOINHIGHjoin-bucket-1
9GROUP BY skewHIGHskew-groupby1
10Mapper / Reducer / map agg / output mergeHIGHmr-4
11count distinct / sorting / JOIN orderMEDIUMvarious3
12NULL skew / parallel / speculativeMEDIUMvarious3
13Dynamic partition / engine choiceMEDIUMengine-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 Join
  • storage-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; avoid SELECT *
  • query-predicate-pushdown — predicate pushdown; outer-join filters in ON
  • query-cbo-stats — enable CBO and ANALYZE statistics
  • query-vectorization — vectorized execution for ORC tables
  • query-count-distinct — two-stage rewrite to avoid single Reducer
  • query-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 large
  • join-order — filter first, join later; largest table last

Data Skew (skew)

  • skew-groupby — map-side aggregation + groupby.skewindata two-stage
  • skew-null — filter or salt NULL/default join keys

MapReduce Parameters (mr)

  • mr-mapper-count — control Mapper count via split size and CombineHiveInputFormat
  • mr-reducer-count — auto-estimate Reducers via bytes.per.reducer
  • mr-map-aggr — enable map-side aggregation to reduce Shuffle
  • mr-merge-output — merge output small files at job end
  • mr-parallel — parallel execution of independent stages
  • mr-speculative — manage speculative execution for skew / external-table scenarios

Engine & Advanced (engine)

  • engine-dynamic-partition — correct dynamic-partition config + DISTRIBUTE BY to control file count
  • engine-consider-tez — evaluate Tez/Spark when MR is the bottleneck

When to Trigger This Skill

Enable when you encounter:

  • CREATE TABLE / ALTER TABLE statements
  • 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

Keep looking

Skills are one crate of 326,835. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.