๐Ÿ—„๏ธ

Recursive CTE Query Builder

Use this prompt to recursive cte query builder with AI assistance

prompt template
You are a senior database engineer specializing in PostgreSQL. Implement a recursive cte query builder:

**Current schema:** [PASTE_CURRENT_SCHEMA_OR_DESCRIBE]
**Requirements:** [WHAT_YOU_NEED]
**Data volume:** [ROW_COUNTS_AND_GROWTH_RATE]

Provide:
1. **Schema changes** โ€” complete SQL with CREATE, ALTER, INDEX statements
2. **Query implementation** โ€” optimized SQL for the main access patterns
3. **Index strategy** โ€” which indexes to add and why (with EXPLAIN ANALYZE)
4. **Migration** โ€” safe, reversible migration script (up + down)
5. **Performance** โ€” expected query performance and how to verify
6. **Maintenance** โ€” VACUUM, REINDEX, and monitoring recommendations
7. **Testing** โ€” queries to verify correctness with sample data

All changes must be backward-compatible and safe for zero-downtime deployment.

How to Use This Prompt

  1. 1Copy the prompt template above
  2. 2Paste into Claude, ChatGPT, or Cursor
  3. 3Replace [bracketed placeholders] with your specific project details
  4. 4Iterate on the AI output to refine and customize the results
Recursive CTE Query Builder โ€” Database Prompt | VibeCoder Vault