[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74G9VHSSHT95GAJNQZRH7K6":3,"skill-same:01M74G9VHSSHT95GAJNQZRH7K6":44},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M74G9VHSSHT95GAJNQZRH7K6","nosql-partition-design",null,"Design NoSQL access patterns and partition keys (DynamoDB, Cassandra, Cosmos, Mongo) — hot partitions, indexes, throughput, TTL.","MohammadBafkar\u002Fpolymath","MohammadBafkar","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F34940462?v=4","01M74G540TQFZWK6KVAPKFVGNR","Mohammad Bafkar","01M74G541HG19QP9V5DQCJVKYE",0,"MIT","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-database\u002Fskills\u002Fnosql-partition-design\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: nosql-partition-design\ndescription: Design NoSQL access patterns and partition keys (DynamoDB, Cassandra, Cosmos, Mongo) — hot partitions, indexes, throughput, TTL.\n---\n\n# nosql-partition-design\n\n> In key-value and wide-column stores you model the queries, not the entities. The partition key decides throughput ceiling, latency, and cost — and can't be changed without a migration.\n\n**Mode:** analytical — judgment inside a fixed frame. Keep the output shape; every verdict cites its evidence; unknowns are marked `[TBD]` or `[VERIFY]`, never filled in.\n\n## When to use\n\n- Designing a DynamoDB \u002F Cassandra \u002F ScyllaDB \u002F Cosmos DB \u002F Bigtable \u002F MongoDB data model.\n- Throttling (`ProvisionedThroughputExceeded`, 429 \u002F `RequestRateTooLarge`), a hot partition, large partitions, or runaway cost.\n- Deciding whether a workload fits a NoSQL store at all.\n\nNot this when: the store is relational and the question is sharding — `polymath-database:partitioning-sharding`. Index design in a relational engine — `polymath-database:index-strategy`.\n\n## Inputs\n\n- The access patterns, enumerated: each query\u002Fwrite with its key, frequency (per second at peak), latency target, result size, and consistency need.\n- Entity sizes and relationships; cardinality and skew of candidate keys (top tenant, hottest item).\n- The store, its capacity mode (on-demand vs provisioned throughput \u002F RU\u002Fs), and its limits (item size, partition size, per-partition throughput) — check current documentation for the numbers; they change.\n\n## Procedure\n\n1. **List every access pattern first** (a table: pattern · key attributes · read\u002Fwrite · rate · latency). The model is derived from this list; a pattern not on it is not supported.\n2. **Choose the partition key for distribution and locality.** It must (a) have high cardinality, (b) spread request *rate* and *data size* evenly — a key that is evenly populated can still be hot (a \"today\" key, a viral item, one big tenant), (c) be the equality predicate of the hot queries. A queries-by-partition-key read is a single-partition operation; anything else is a scan or fan-out.\n3. **Choose the sort\u002Fclustering key** to make range reads and ordering free within a partition: time-ordered ids, composite sort keys that group related items so one `Query` returns an aggregate with its children (single-table design in DynamoDB; wide rows in Cassandra).\n4. **Keep partitions bounded.** Unbounded growth (all events for a device forever) breaks per-partition size limits and read latency: bucket by time (`device#2025-10`), by hash suffix, or cap and roll over. Choose bucket size from measured volume, with a plan for readers to enumerate buckets.\n5. **Spread hot keys deliberately.** Write sharding by appending a suffix (`item#0..N`) trades one hot partition for N reads to aggregate; cache or CDN hot reads (DAX \u002F app cache) before sharding keys; queue and batch write bursts. Adaptive capacity helps imbalance, not a single hot key.\n6. **Secondary access patterns.** Local\u002Fglobal secondary indexes (DynamoDB GSI\u002FLSI), materialized views \u002F SAI (Cassandra), partition-key-changing indexes (Cosmos). Each GSI is a second table: costs write throughput, is eventually consistent, and has its own hot-key risk — project only the attributes needed. Prefer a denormalized duplicate item written in the same transaction\u002Fbatch over a join that doesn't exist.\n7. **Denormalize with a consistency plan.** Duplicated data must be updated together (transactions where the store has them, otherwise idempotent writers + a repair job). Avoid read-modify-write races with conditional writes \u002F optimistic version attributes \u002F lightweight transactions only where required (LWTs and cross-partition transactions cost latency and throughput).\n8. **Consistency and quorum.** Eventual vs strong reads (DynamoDB), tunable consistency (`LOCAL_QUORUM` vs `ONE`, Cosmos levels). State the choice per pattern and the multi-region implication.\n9. **Capacity and cost.** Convert peak rates and item sizes into throughput units for the store (read\u002Fwrite capacity units or RU — use the vendor's current formula), add GSI write amplification, decide on-demand vs provisioned with autoscaling, and compute the per-partition share against the per-partition limit. Large items and scans are the usual cost surprise — project less, compress, or offload payloads to object storage with a pointer.\n10. **Lifecycle.** TTL for expiring data (note: DynamoDB TTL deletion is asynchronous, doesn't consume write capacity, and still emits stream events; Cassandra TTL creates tombstones — mind `gc_grace_seconds` and time-window compaction), export\u002Farchive to the lake (`polymath-database:data-retention-archiving`), and a backup\u002Fpoint-in-time-recovery setting.\n11. **Fit check.** If most patterns need ad hoc queries, joins, or multi-entity transactions, the access pattern is relational — say so and stop (`polymath-database:db-scaling-strategy`).\n\n## Output\n\n```text\nNoSQL model: device telemetry + device registry (DynamoDB, on-demand → provisioned later)\n\nAccess patterns\n  A1 get device profile                     pk=DEVICE#\u003Cid>, sk=PROFILE                    3k\u002Fs read   p99 \u003C 10 ms\n  A2 latest N readings for a device         pk=DEVICE#\u003Cid>#\u003Cyyyymm>, sk=TS#\u003Ciso>, rev     20k\u002Fs write 6k\u002Fs read\n  A3 devices in a site                      GSI1 pk=SITE#\u003Cid>, sk=DEVICE#\u003Cid>              50\u002Fs read\n  A4 all devices with open alert            sparse GSI2 pk=ALERT#open, sk=\u003Csite>#\u003Cid> + write-shard suffix (0–7)   5\u002Fs read\nKeys\n  Reading partitions bucketed per device-month: bounds partition size (≈ 21 MB\u002Fmonth at 1 reading\u002Fmin × 0.5 KB [VERIFY: measured item size]); readers enumerate ≤ 2 buckets for \"latest\".\n  Hot-key check: top device = 0.02% of writes; site GSI top site = 3% (acceptable) — [VERIFY quarterly].\nAlerts index is sparse and write-sharded (8 suffixes) so one `ALERT#open` key can't throttle; A4 reads 8 keys in parallel.\nConsistency: A1 strongly consistent read after registration; A2\u002FA3 eventual.\nCapacity: A2 20k writes\u002Fs × 0.5 KB items → [TBD: units from vendor formula] + GSI writes; per-partition write share ≈ 20k\u002F(devices spread) — within limits because pk spreads across 120k devices.\nLifecycle: TTL 90 d on readings; nightly export to S3 (Parquet) for analytics; PITR on.\nRejected: single \"readings\" partition per site (hot, unbounded); scan for open alerts (cost).\n```\n\n## Quality bar\n\n- Every access pattern has a key path; none is served by a scan unless explicitly accepted and costed.\n- The partition key is checked for *rate* skew as well as data skew, with the hot-key mitigation named.\n- Partition growth is bounded, and GSIs' costs and consistency are stated.\n- Capacity is computed from rates and item sizes using the vendor's current formula, or marked `[TBD]`.\n- Denormalized copies have a defined consistency mechanism.\n\n## Anti-patterns to avoid\n\n- Modeling entities first and discovering the queries later.\n- A low-cardinality or time-only partition key (`status`, `date`) — one partition takes all the writes.\n- Unbounded partitions (all history under one key) and giant items.\n- Using scans or filter expressions as the query path; filters don't reduce read cost.\n- A GSI\u002FMV per ad hoc question — each one multiplies write cost and lag.\n- Picking NoSQL to escape a missing relational index.\n","# nosql-partition-design\n\n> In key-value and wide-column stores you model the queries, not the entities. The partition key decides throughput ceiling, latency, and cost — and can't be changed without a migration.\n\n**Mode:** analytical — judgment inside a fixed frame. Keep the output shape; every verdict cites its evidence; unknowns are marked `[TBD]` or `[VERIFY]`, never filled in.\n\n## When to use\n\n- Designing a DynamoDB \u002F Cassandra \u002F ScyllaDB \u002F Cosmos DB \u002F Bigtable \u002F MongoDB data model.\n- Throttling (`ProvisionedThroughputExceeded`, 429 \u002F `RequestRateTooLarge`), a hot partition, large partitions, or runaway cost.\n- Deciding whether a workload fits a NoSQL store at all.\n\nNot this when: the store is relational and the question is sharding — `polymath-database:partitioning-sharding`. Index design in a relational engine — `polymath-database:index-strategy`.\n\n## Inputs\n\n- The access patterns, enumerated: each query\u002Fwrite with its key, frequency (per second at peak), latency target, result size, and consistency need.\n- Entity sizes and relationships; cardinality and skew of candidate keys (top tenant, hottest item).\n- The store, its capacity mode (on-demand vs provisioned throughput \u002F RU\u002Fs), and its limits (item size, partition size, per-partition throughput) — check current documentation for the numbers; they change.\n\n## Procedure\n\n1. **List every access pattern first** (a table: pattern · key attributes · read\u002Fwrite · rate · latency). The model is derived from this list; a pattern not on it is not supported.\n2. **Choose the partition key for distribution and locality.** It must (a) have high cardinality, (b) spread request *rate* and *data size* evenly — a key that is evenly populated can still be hot (a \"today\" key, a viral item, one big tenant), (c) be the equality predicate of the hot queries. A queries-by-partition-key read is a single-partition operation; anything else is a scan or fan-out.\n3. **Choose the sort\u002Fclustering key** to make range reads and ordering free within a partition: time-ordered ids, composite sort keys that group related items so one `Query` returns an aggregate with its children (single-table design in DynamoDB; wide rows in Cassandra).\n4. **Keep partitions bounded.** Unbounded growth (all events for a device forever) breaks per-partition size limits and read latency: bucket by time (`device#2025-10`), by hash suffix, or cap and roll over. Choose bucket size from measured volume, with a plan for readers to enumerate buckets.\n5. **Spread hot keys deliberately.** Write sharding by appending a suffix (`item#0..N`) trades one hot partition for N reads to aggregate; cache or CDN hot reads (DAX \u002F app cache) before sharding keys; queue and batch write bursts. Adaptive capacity helps imbalance, not a single hot key.\n6. **Secondary access patterns.** Local\u002Fglobal secondary indexes (DynamoDB GSI\u002FLSI), materialized views \u002F SAI (Cassandra), partition-key-changing indexes (Cosmos). Each GSI is a second table: costs write throughput, is eventually consistent, and has its own hot-key risk — project only the attributes needed. Prefer a denormalized duplicate item written in the same transaction\u002Fbatch over a join that doesn't exist.\n7. **Denormalize with a consistency plan.** Duplicated data must be updated together (transactions where the store has them, otherwise idempotent writers + a repair job). Avoid read-modify-write races with conditional writes \u002F optimistic version attributes \u002F lightweight transactions only where required (LWTs and cross-partition transactions cost latency and throughput).\n8. **Consistency and quorum.** Eventual vs strong reads (DynamoDB), tunable consistency (`LOCAL_QUORUM` vs `ONE`, Cosmos levels). State the choice per pattern and the multi-region implication.\n9. **Capacity and cost.** Convert peak rates and item sizes into throughput units for the store (read\u002Fwrite capacity units or RU — use the vendor's current formula), add GSI write amplification, decide on-demand vs provisioned with autoscaling, and compute the per-partition share against the per-partition limit. Large items and scans are the usual cost surprise — project less, compress, or offload payloads to object storage with a pointer.\n10. **Lifecycle.** TTL for expiring data (note: DynamoDB TTL deletion is asynchronous, doesn't consume write capacity, and still emits stream events; Cassandra TTL creates tombstones — mind `gc_grace_seconds` and time-window compaction), export\u002Farchive to the lake (`polymath-database:data-retention-archiving`), and a backup\u002Fpoint-in-time-recovery setting.\n11. **Fit check.** If most patterns need ad hoc queries, joins, or multi-entity transactions, the access pattern is relational — say so and stop (`polymath-database:db-scaling-strategy`).\n\n## Output\n\n```text\nNoSQL model: device telemetry + device registry (DynamoDB, on-demand → provisioned later)\n\nAccess patterns\n  A1 get device profile                     pk=DEVICE#\u003Cid>, sk=PROFILE                    3k\u002Fs read   p99 \u003C 10 ms\n  A2 latest N readings for a device         pk=DEVICE#\u003Cid>#\u003Cyyyymm>, sk=TS#\u003Ciso>, rev     20k\u002Fs write 6k\u002Fs read\n  A3 devices in a site                      GSI1 pk=SITE#\u003Cid>, sk=DEVICE#\u003Cid>              50\u002Fs read\n  A4 all devices with open alert            sparse GSI2 pk=ALERT#open, sk=\u003Csite>#\u003Cid> + write-shard suffix (0–7)   5\u002Fs read\nKeys\n  Reading partitions bucketed per device-month: bounds partition size (≈ 21 MB\u002Fmonth at 1 reading\u002Fmin × 0.5 KB [VERIFY: measured item size]); readers enumerate ≤ 2 buckets for \"latest\".\n  Hot-key check: top device = 0.02% of writes; site GSI top site = 3% (acceptable) — [VERIFY quarterly].\nAlerts index is sparse and write-sharded (8 suffixes) so one `ALERT#open` key can't throttle; A4 reads 8 keys in parallel.\nConsistency: A1 strongly consistent read after registration; A2\u002FA3 eventual.\nCapacity: A2 20k writes\u002Fs × 0.5 KB items → [TBD: units from vendor formula] + GSI writes; per-partition write share ≈ 20k\u002F(devices spread) — within limits because pk spreads across 120k devices.\nLifecycle: TTL 90 d on readings; nightly export to S3 (Parquet) for analytics; PITR on.\nRejected: single \"readings\" partition per site (hot, unbounded); scan for open alerts (cost).\n```\n\n## Quality bar\n\n- Every access pattern has a key path; none is served by a scan unless explicitly accepted and costed.\n- The partition key is checked for *rate* skew as well as data skew, with the hot-key mitigation named.\n- Partition growth is bounded, and GSIs' costs and consistency are stated.\n- Capacity is computed from rates and item sizes using the vendor's current formula, or marked `[TBD]`.\n- Denormalized copies have a defined consistency mechanism.\n\n## Anti-patterns to avoid\n\n- Modeling entities first and discovering the queries later.\n- A low-cardinality or time-only partition key (`status`, `date`) — one partition takes all the writes.\n- Unbounded partitions (all history under one key) and giant items.\n- Using scans or filter expressions as the query path; filters don't reduce read cost.\n- A GSI\u002FMV per ad hoc question — each one multiplies write cost and lag.\n- Picking NoSQL to escape a missing relational index.\n",{"name":5,"description":7},"main","23f6e21841a39580c9da2b5ec941f39dda17cd86","plugins\u002Fpolymath-database\u002Fskills\u002Fnosql-partition-design","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath","https:\u002F\u002Fgithub.com\u002FMohammadBafkar","2026-10-29 18:34:59",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add MohammadBafkar\u002Fpolymath --skill nosql-partition-design",{"tool":36,"command":37},"bunx","bunx skills add MohammadBafkar\u002Fpolymath --skill nosql-partition-design",{"tool":39,"command":40},"pnpm","pnpm dlx skills add MohammadBafkar\u002Fpolymath --skill nosql-partition-design","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-database\u002Fskills\u002Fnosql-partition-design\u002FSKILL.md",true,[],[45,52,59,66,73,80],{"skillNo":46,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"publishedAt":19},"01M74GN87EBRHM9N87M7AP1HDD","runbook","Write or refresh an operational runbook for an alert\u002Fsymptom; structured as TL;DR + Pre-checks + Steps + Verification + Rollback + Escalation.","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Frunbook\u002FSKILL.md",[],[],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M74GN5GPKEC1JEKP2DFQNEQJ","rfc","Draft a lightweight design RFC to docs\u002Frfcs\u002F\u003Cslug>.md; Summary, Motivation, Detailed design, Drawbacks, Alternatives, Unresolved questions. A proposal to debate, not a recorded decision (adr).","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Frfc\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M74GN2F4CWPMV4X09TG4E304","editorial-pass","Review and tighten prose in a Markdown artifact for a target tone (terse, formal, friendly) without dropping information; preserve quotations and load-bearing constraints.","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Feditorial-pass\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M74GMZWGYMZ37C4DYGT6P23G","architecture-review-facilitation","Run an architecture review as a process — entry criteria, reviewer checklist, decision log, and follow-up actions — pairing the design artifact with a red-team pass.","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Farchitecture-review-facilitation\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M74GMXVX0YX3ETDXS527XDGM","architecture-doc","Write a C4-style architecture document; System Context + Containers (+ Components when interesting) with mermaid diagrams. Describes structure, not a decision (adr) or proposal (rfc).","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Farchitecture-doc\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M74GMVG1WSMCK066S3KE6V5K","adr","Write an Architecture Decision Record (Michael Nygard format) to docs\u002Fadrs\u002FNNNN-\u003Cslug>.md; frontmatter validated by the ADR artifact schema. Records a made decision, not a proposal to debate (rfc).","https:\u002F\u002Fgithub.com\u002FMohammadBafkar\u002Fpolymath\u002Fblob\u002Fmain\u002Fplugins\u002Fpolymath-writing\u002Fskills\u002Fadr\u002FSKILL.md",[],[]]