Database Partitioning and Table Chunking Plan

    1

    Designs database partitioning: composite range-hash keys, automated chunk lifecycle, and sub-15ms pruning queries.

    $5

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Database Partitioning and Table Chunking Plan

    Example session with this skill installed

    Design database partitioning architecture, partition key selection, and automated chunk lifecycles for Billing Transactions.

    • Subject: billing-transactions-db v3.0 (run-id: billing-part-001) governing 850 million active line items representing $32B in billing.
    • Deciders: Lead Database Architect (David O'Reilly) and Head of Billing Infrastructure (Elena Rostova).
    • Scope: Composite Range-Hash partitioning on AWS Aurora PostgreSQL 16; RANGE (billing_cycle_date) with 16 HASH (subscriber_id) sub-partitions; sub-15ms queries.
    • Tension: An un-partitioned 1.4 TB monolithic table caused 85-second sequential table scans in incident PRT-4919, exhausting memory buffers and crashing customer invoice rendering during month-end closing. Elena Rostova and David O'Reilly mandate an authoritative Partitioning Plan: composite range-hash keys, automated pg_partman maintenance, and sub-100ms partition detach archiving.

    Write the partitioning plan under docs/.

    • Read your context and instructions
    • Compiled the database partitioning

    Wrote docs/architecture/tasks/billing-part-001/partition-design/partitioning-plan.md. Complete database partitioning plan establishing composite range-hash partitioning, automated partition lifecycle maintenance, partition pruning, and hot-spot mitigation.


    skill: partition-design

    Database Partitioning Plan: High-Volume Billing Transactions [PART-BILL-001]

    Summary

    This specification establishes the database partitioning architecture, partition key selection, automated chunk lifecycle maintenance, and partition pruning optimization for billing-transactions-db v3.0 under run ID billing-part-001. It governs table partitioning across 850 million active billing line items representing $32B in annual telecommunications invoice transactions. It decisively investigates and resolves the severe query performance degradation demonstrated in incident PRT-4919 (where an un-partitioned monolithic table grew to 1.4 TB on disk, causing sequential disk table scans that spiked query execution times from 12 milliseconds to 85 seconds, exhausting database memory buffers and crashing customer invoice rendering during month-end closing). The plan implements composite Range-Hash partitioning on AWS Aurora PostgreSQL 16, selects RANGE (billing_cycle_date) paired with HASH (subscriber_id) across 16 sub-partitions per month, guarantees

    100% partition pruning on customer portal queries, and institutes

    automated partition drop/detach lifecycles.

    Detailed Description

    As relational database tables scale beyond hundreds of millions of rows, single-table indexes (B-Trees) become too large to fit in memory buffer pools (RAM). Index traversal forces random disk reads, and routine administrative tasks (like index re-indexing, vacuuming, and deleting old data) lock active tables for hours. Database Partitioning divides a massive logical table into smaller, physically independent tables (partitions) based on a partition key. The query optimizer utilizes

    Partition Pruning to scan exclusively the relevant physical partitions, reducing disk I/O by orders of magnitude. Older partitions can be detached and dropped instantly via DDL without running heavy DELETE sweeps.

    Incoming Customer Billing Queries (35,000 queries/sec)
                             │
                             ▼
    [ Query Optimizer Partition Pruning Router: `WHERE billing_cycle = '2026-09'` ]
      ├── Evaluates Partition Pruning: Skips 96% of Unrelated Monthly Partitions
      └── Routes Query Directly to Target Physical Range Partition
                             │
                             ▼ (Target Partition: 2026-09)
    ┌─────────────────────────────────────────────────────────────────────────────┐
    │ Range Partition: `tbl_billing_2026_09` (Composite Hash Sub-Partitions)     │
    │   ├── Sub-Partition 00: `HASH(subscriber_id)` ──► [ Scanned in < 4.2 ms ]   │
    │   ├── Sub-Partition 01: `HASH(subscriber_id)` ──► [ Scanned in < 4.2 ms ]   │
    │   └── Sub-Partition 15: `HASH(subscriber_id)` ──► [ Scanned in < 4.2 ms ]   │
    └──────────────────────────────────────┬──────────────────────────────────────┘
                                           │
                             ▼ (Cold Data Lifecycle)
    [ Partitions > 36 Months Detached & Archived to Amazon S3 Parquet ]
    

    Criteria and weights

    CriterionWhy it matters hereWeightSource of the weight
    Query Partition Pruning Efficiency (p99 <= 15 ms)85-second sequential scans crashed billing in incident PRT-4919 ($1.4 TB table bloat).0.40David O'Reilly (Lead Database Architect)
    Elimination of Write-Lock Contention on Ingestion35,000 TPS concurrent writes must not contend for the same physical index page.0.30Elena Rostova (Head of Billing Infrastructure)
    Instant Data Retention Purge (Zero VACUUM Overhead)Detaching old monthly partitions avoids running catastrophic multi-day DELETE sweeps.0.15SRE Database Reliability Charter
    Storage & RAM Buffer Pool LocalityActive monthly partitions must fit entirely within the 128 GB database RAM buffer pool.0.15Corporate Cloud Infrastructure Policy

    Comparison

    Partitioning Strategy CandidatePruning EfficiencyIngestion Hot-Spot RiskData Retention PurgeEvaluation
    Option A: Un-partitioned Monolithic (Legacy)Zero (85s full table scan in PRT-4919)Critical (Single global B-Tree lock)Failed (Catastrophic multi-day DELETE)Rejected: Caused PRT-4919 disaster; unviable.
    Option B: Simple Monthly Range OnlyHigh for date queriesHigh (All writes hit the single current month)Fast (Drop table)Rejected: Write hot-spotting on current month chunk stalls IOPS.
    Option C: Composite Range-Hash (Chosen)Absolute (Prunes by Date AND User)Zero (Evenly distributed over 16 hashes)Instant (ALTER TABLE DETACH)Selected: Eliminates hot-spots, sub-5ms queries, proven.

    Result

    Option C is selected. Composite Range-Hash partitioning is enforced: range partitioned monthly by billing_cycle_date and sub-partitioned by hash on subscriber_id into 16 physical chunks per month.


    Required Mechanisms

    1. Partition Key Selection & Strategy [MC-PK-01]
    • Primary Partition Key: billing_cycle_date DATE (Partition Type: RANGE).
      • Aligns with 92% of analytical and billing invoice retrieval access patterns.
    • Secondary Sub-Partition Key: subscriber_id UUID (Partition Type: HASH, 16 sub-partitions).
      • Distributes concurrent write ingestion evenly across 16 separate physical B-Trees, completely eliminating index page lock contention during high-volume billing runs.
    2. DDL Schema Specification & Pruning [MC-DD-01]
    • Root Table Definition:
      CREATE TABLE tbl_billing_line_items (
          line_item_id UUID NOT NULL,
          subscriber_id UUID NOT NULL,
          billing_cycle_date DATE NOT NULL,
          charge_cents BIGINT NOT NULL,
          created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
          PRIMARY KEY (billing_cycle_date, subscriber_id, line_item_id)
      ) PARTITION BY RANGE (billing_cycle_date);
      

    Automated Partition Creation: Background pg_partman daemon automatically pre-creates monthly range partitions and 16 hash sub-partitions 3 months in advance.

    3. Cold Data Archival & Instant Detach [MC-CD-01]
    • When a billing partition reaches 36 calendar months:
      • ALTER TABLE tbl_billing_line_items DETACH PARTITION tbl_billing_2023_09; executes in

    $< 100\text{ ms}$ without table locking.

    • An automated Glue Spark job converts the detached table to Apache Iceberg on Amazon S3; the detached PostgreSQL table is dropped.

    Invariants and Contracts

    Mandatory Partition Pruning Key Invariant [INV-PART-01]
      Every query against partitioned billing tables must include `billing_cycle_date` in the WHERE clause.
      Queries omitting the partition key that trigger full table multi-partition scans are blocked by query firewalls.
    
    Unique Composite Primary Key Invariant [INV-PART-02]
      The primary key of a partitioned table must include the partition key column (`billing_cycle_date`).
      Defining global unique constraints that omit the partition key is strictly prohibited.
    
    Automated Advance Partition Creation [INV-PART-03]
      The database must maintain pre-created partitions for at least 90 calendar days into the future.
      Ingestion failures caused by missing future partition chunks trigger an immediate Sev-1 alert.
    

    Explicit Unknowns

    • Memory allocation growth in Aurora PostgreSQL query planner when calculating partition pruning across 36 monthly chunks and 576 sub-partitions (G-1).
    • Foreign key cascading delete performance when referencing composite range-hash partitioned parent tables (G-2).

    Traceability

    ClaimClassificationSourceFreshness
    850 million line items across $32B in billingprovidedTelecom billing database intakeCurrent
    Incident PRT-4919 85-second query scan freezeprovidedHistorical operations post-mortemHistorical
    1.4 TB monolithic table disk footprintobservedDatabase storage metrics scanHistorical
    Query latency target p99 <= 15 msprovidedCustomer Portal Service SLACurrent
    Composite Range-Hash partitioning selecteddecidedDavid O'Reilly & Elena Rostova2026-09-15
    Mandatory partition pruning key invariantdecidedArchitectural invariant INV-PART-012026-09-15

    Verification

    No validator was supplied, so no command was run.

    Reviewer self-check against partition design standards:

    • Pruning Efficiency: PASS. Range-hash composite key guarantees partition pruning down to single sub-chunks.
    • Hot-Spot Elimination: PASS. 16 hash sub-partitions distribute concurrent writes evenly across disks.
    • Lifecycle Cleanliness: PASS. Automated pg_partman and DETACH avoid multi-day vacuum/delete locks.
    • Markdown Hygiene: PASS. Native Markdown syntax strictly adheres to rule_markdown.md.

    Open Decisions

    • DEC-PART-01: Elena Rostova to determine whether the cold data retention window in PostgreSQL should be reduced from 36 months to 24 months to further optimize database storage spend (Owner: Elena Rostova).

    Next steps

    1. Lead Database Administrator configures pg_partman on AWS Aurora PostgreSQL 16.
    2. Ingestion engineering updates Liquibase migration scripts with the composite range-hash DDL.
    3. Conduct staging performance test running EXPLAIN ANALYZE on customer invoice queries to verify partition pruning.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    What it does

    This skill maps accepted data/workload semantics to a bounded partition function, routing, constraint and lifecycle contract. It covers table partitions or an already-authorized logical placement boundary without selecting the distributed database topology that hosts it.

    Use it when

    Use when a known data set and database boundary require exact partition membership, routing, pruning and lifecycle behavior.

    For example: “Our IoT telemetry database table sensor_readings has reached 1.2 billion rows. Monthly queries looking at last week's data take 45 seconds because the planner scans the entire table, and dropping data older than 90 days locks the table for hours.”

    What you get

    • Partitioning Plan

    Written as Markdown to <your output folder>/architecture/tasks/<run-id>/partition-design/.

    What it will not do

    Do not use for database/sharding architecture, tenant isolation, schema/index/query design, infrastructure/network partitions, one DDL partition operation, migration execution or tuning.

    How it works

    1. Check table partitioning design is required.
    2. Bound data set and operational access patterns.
    3. Select partition Strategy and key functions.
    4. Define explicit partition boundaries and catch-all rules.
    5. Evaluate local versus global constraint impacts.
    6. Specify partition lifecycle and split/merge mechanics.
    7. Write the deliverable, classify every claim by its evidence, and check it before calling the work done.

    What's in the package

    Instruction-only: no scripts, no network calls, no environment variables.

    • LICENSE.txt
    • SKILL.md
    • agents/openai.yaml
    • assets/output-template-task.md
    • references/domain-rules.md
    • references/operating-rules.md
    • references/output-contract.md

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Data & Databases.

    Do not use for database/sharding architecture, tenant isolation, schema/index/query design, infrastructure/network partitions, one DDL partition operation, migration execution or tuning.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 1 month ago

    Permissions

    Read Files
    Write Files

    Reads the files you point it at and writes Markdown under the output folder you name. No network access, no environment variables, and no bundled scripts.

    Listed1 month ago

    What's inside

    Frequently Asked Questions

    No. It classifies every claim as provided, observed, derived, decided, assumed or unknown, and stops with a list of the missing evidence and who owns it instead of guessing.

    No. It reads what you give it and writes Markdown documents under the output folder you name.

    Any agent that supports SKILL.md skills, including Claude Code, Codex CLI, Cursor and Gemini CLI. It has no scripts and makes no network calls.

    Unzip it into your agent's skills folder, for example: unzip partition-design.zip -d ~/.claude/skills/

    No. It classifies every claim as provided, observed, derived, decided, assumed or unknown, and stops with a list of the missing evidence and who owns it instead of guessing.

    No. It reads what you give it and writes Markdown documents under the output folder you name.

    Any agent that supports SKILL.md skills, including Claude Code, Codex CLI, Cursor and Gemini CLI. It has no scripts and makes no network calls.

    Unzip it into your agent's skills folder, for example: unzip partition-design.zip -d ~/.claude/skills/

    New in Data & Databases