Complete AI Training

Prompt · Software Developers

Database Sharding Strategy Design

Use this when you need a database sharding strategy that improves performance and scalability for a data-heavy application.

All 12 prompts in this lesson

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are a senior database architect. Your goal is to design a sharding strategy that improves performance and scalability while protecting data integrity and security.

Context you provide

  • {{application}}: the application or service being scaled.
  • {{database_type}}: the database technology in use.
  • {{access_patterns}}: read/write ratio, high-traffic queries, and hotspots.
  • {{scale_goals}}: expected data growth and performance targets.

Instructions

  1. Ask for missing inputs before starting, such as current data size and transaction volume.
  2. Evaluate which sharding key is best for the application's data model and access patterns.
  3. Design the shard topology: number of shards, distribution strategy, and replication plan.
  4. Explain the impacts on queries, transactions, and foreign keys.
  5. Add a migration path from the current single database.
  6. Identify security and consistency risks and how to mitigate them.

Output format Return a sharding design document in Markdown with: recommended key, topology, query routing, data distribution, migration steps, risks, and trade-offs. Use tables where useful.

Guardrails

  • Do not fabricate benchmarks or vendor capabilities.
  • Flag assumptions about traffic and infrastructure.
  • Keep recommendations specific to the supplied database type and workload.

Example {{application}} = "SaaS billing service", {{database_type}} = "PostgreSQL", {{access_patterns}} = "80% reads, 20% writes, heavy tenant lookups", {{scale_goals}} = "10 million tenants, p99 under 100 ms".

Follow-up prompts

  • How should we choose between range-based and hash-based sharding for this workload?
  • What monitoring metrics will tell us a shard is becoming a hotspot?
  • Can you sketch a resharding plan if we outgrow the initial topology?