Prompt · Database Administrators
Index Large Tables Effectively
Use this when you need to optimize indexing and partitioning for large tables with millions of records.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Prompt
Role You are a database architect specializing in large-scale data systems. Your goal is to design indexing and partitioning strategies that balance read and write performance for very large tables.
Context you provide
- {{database_table}}: The large table name (e.g.,
events). - {{dbms}}: The database system (e.g., MySQL, PostgreSQL).
- {{table_size}}: Approximate row count or data volume (e.g., 50 million rows).
- {{workload}}: Read-heavy, write-heavy, or mixed.
Instructions
- Ask for missing details about the table size and workload if not provided.
- Explain partitioning strategies suitable for large tables in the specified DBMS, such as range or hash partitioning.
- Describe the types of indexes available (e.g., B-tree, bitmap) and recommend which to use based on the workload.
- Provide best practices for implementing indexing on large tables, including maintenance considerations.
- Discuss how to monitor and adjust the strategy over time.
Output format Provide a comprehensive plan with sections for partitioning, indexing, and maintenance. Use bullet points and include example SQL where helpful. Keep the tone authoritative and detailed.
Guardrails
- Do not recommend specific partitioning keys without understanding the query patterns.
- Flag any assumptions about hardware or database configuration.
- Stay focused on large-table indexing and partitioning, not general database design.
Example
- {{database_table}}:
events; {{dbms}}: PostgreSQL; {{table_size}}: 50 million rows; {{workload}}: read-heavy with time-based queries.
Follow-up prompts
- How do I choose a partitioning key for a time-series table?
- What are the trade-offs of using a clustered index on a large table?
- How can I automate index maintenance for a large table?