|
14 | 14 | <a href="#overview">Overview</a> • |
15 | 15 | <a href="#demo">Demo</a> • |
16 | 16 | <a href="#quick-start">Quick Start</a> • |
17 | | - <a href="#features">Features</a> • |
18 | 17 | <a href="#technical-notes">Technical Notes</a> • |
19 | 18 | <a href="#mcp-server-api">MCP API</a> • |
20 | 19 | <a href="#related-projects">Related Projects</a> |
|
27 | 26 | **Postgres Pro** is an open source Model Context Protocol (MCP) server built to support you and your AI agents throughout the **entire development process**—from initial coding, through testing and deployment, and to production tuning and maintenance. |
28 | 27 |
|
29 | 28 | Postgres Pro does much more than wrap a database connection. |
30 | | -For example, it provides: |
31 | | -- 🚀 **Industrial-stength index tuning** it efficiently explores thousands of possible indexes to find the best solution for your workload, using algorithms similar to those found in commercial databases. |
32 | | -- 🤖 **"What if?" scenario analysis** allowing AI agents to simulate changes based on production data distributions and query patterns. |
33 | | -- 🔍 **Production Health Diagnostics** providing standardized, comprehensive health checks to identify potential issues before they impact performance |
34 | | -- 🛡️ **Safe SQL Execution** - implements restricted execution, ensuring read-only and resource-limited execution to protect production databases |
35 | 29 |
|
36 | | -Postgres Pro also provides comprehensive schema information to support SQL generation, explain plans, and more. |
| 30 | +Features include: |
| 31 | + |
| 32 | +<table> |
| 33 | + <tr> |
| 34 | + <td width="50%"> |
| 35 | + <h4>🔍 Database Health</h4> |
| 36 | + <ul> |
| 37 | + <li>Detect unused/duplicate indexes</li> |
| 38 | + <li>Monitor cache hit rates</li> |
| 39 | + <li>Check connection utilization</li> |
| 40 | + <li>Identify vacuum needs before problems occur</li> |
| 41 | + </ul> |
| 42 | + </td> |
| 43 | + <td width="50%"> |
| 44 | + <h4>⚡ Index Tuning</h4> |
| 45 | + <ul> |
| 46 | + <li>Generate optimal indexes using proven algorithms</li> |
| 47 | + <li>Validate AI-suggested indexes</li> |
| 48 | + <li>Simulate performance impacts with hypothetical indexes</li> |
| 49 | + <li>Balance performance gain vs storage costs</li> |
| 50 | + </ul> |
| 51 | + </td> |
| 52 | + </tr> |
| 53 | + <tr> |
| 54 | + <td width="50%"> |
| 55 | + <h4>📊 Schema Intelligence</h4> |
| 56 | + <ul> |
| 57 | + <li>Detailed schema information for tables, views & more</li> |
| 58 | + <li>Context-aware SQL generation</li> |
| 59 | + <li>Optimal column selection recommendations</li> |
| 60 | + </ul> |
| 61 | + </td> |
| 62 | + <td width="50%"> |
| 63 | + <h4>🔒 Protected Execution</h4> |
| 64 | + <ul> |
| 65 | + <li><b>Unrestricted Mode:</b> Full read/write for development</li> |
| 66 | + <li><b>Restricted Mode:</b> Read-only with resource limits for production</li> |
| 67 | + <li>Safe SQL parsing to prevent security issues</li> |
| 68 | + </ul> |
| 69 | + </td> |
| 70 | + </tr> |
| 71 | +</table> |
37 | 72 |
|
38 | 73 | ## Demo |
39 | 74 |
|
40 | | -Here is a demo of using Postgres Pro in Cursor to fix SQLAlchemy ORM queries in an AI-generated app. |
41 | | -We initially built the app using Replit, but the generated database code ran very slowly, making the application practically unusable. |
| 75 | +*From Unusable to Lightning Fast* |
42 | 76 |
|
43 | | -https://github.com/user-attachments/assets/24e05745-65e9-4998-b877-a368f1eadc13 |
| 77 | +- **Challenge:** We generated a movie app using an AI assistant, but the SQLAlchemy ORM code ran painfully slowly |
| 78 | +- **Solution:** Using Postgres Pro with Cursor, we fixed the performance issues in minutes |
44 | 79 |
|
45 | 80 | **We used the Cursor AI agent and Postgres Pro to:** |
46 | | -- Fix performance - including ORM queries, indexing, and caching |
47 | | -- Fix bugs that require connecting data to code |
48 | | -- Add new features from single prompts |
49 | | - |
50 | | -**Two ways to see demo** |
51 | | - |
52 | | -- Watch video above |
53 | | -- [Read the play-by-play](examples/movie-app.md) |
54 | | - |
55 | | - |
56 | | -## Features |
| 81 | +- 🚀 Fix performance - including ORM queries, indexing, and caching |
| 82 | +- 🛠️ Fix bugs that require connecting data to code |
| 83 | +- 🧠 Add new features from single prompts |
57 | 84 |
|
58 | | -Postgres Pro includes an expanding set of tools covering several areas: |
| 85 | +See the video below or read the [play-by-play](examples/movie-app.md). |
59 | 86 |
|
60 | | -- **Database Health**. |
61 | | - Check cache hit rates, monitor vacuum health, identify unused/duplicate indexes, and more. |
62 | | - |
63 | | -- **Index Tuning**. |
64 | | - Ensure your SQL queries run efficiently and return quickly. |
65 | | - Find tuning targets, validate AI-generated suggestions, or generate candidates using classical index optimization algorithms. |
66 | | - Simulate how Postgres will perform after adding indexes using the explain plans together with [hypothetical indexes](https://hypopg.readthedocs.io/). |
| 87 | +https://github.com/user-attachments/assets/24e05745-65e9-4998-b877-a368f1eadc13 |
67 | 88 |
|
68 | | -- **Schema Information**. |
69 | | - Help your AI Agent generate SQL reliably and successfully with detailed schema information of your database objects—including tables, views, sequences, stored procedures, and triggers. |
70 | 89 |
|
71 | | -- **Protected SQL Execution**. |
72 | | - Work fast or safe, as you choose: |
73 | | - - *Unrestricted Mode:* Provide full read/write access for development environments. Let your AI agent modify data, change the schema, drop tables, whatever you need it to do. |
74 | | - - *Restricted Mode:* Be safe by limiting access in production environments by enforcing checks to ensure read-only operations and limits on resource consumption. |
75 | 90 |
|
76 | 91 |
|
77 | 92 | ## Quick Start |
@@ -338,6 +353,17 @@ There are many MCP servers allow an AI agent to run queries against a Postgres d |
338 | 353 | Postgres Pro does that too, but also adds tools for understanding and improving the performance of your Postgres database. |
339 | 354 | For example, it implements a version of the [Anytime Algorithm of Database Tuning Advisor for Microsoft SQL Server](https://www.microsoft.com/en-us/research/wp-content/uploads/2020/06/Anytime-Algorithm-of-Database-Tuning-Advisor-for-Microsoft-SQL-Server.pdf), a modern industrial-strength algorithm for automatic index tuning. |
340 | 355 |
|
| 356 | +| Postgres Pro | Other Postgres MCP Servers | |
| 357 | +|--------------|----------------------------| |
| 358 | +| ✅ Deterministic database health checks | ❌ Unrepeatable LLM-generated health queries | |
| 359 | +| ✅ Principled indexing search strategies | ❌ Gen-AI guesses at indexing improvements | |
| 360 | +| ✅ Workload analysis to find top problems | ❌ Inconsistent problem analysis | |
| 361 | +| ✅ Simulates performance improvements | ❌ Try it yourself and see if it works | |
| 362 | + |
| 363 | +Postgres Pro complements generative AI by adding deterministic tools and classical optimization algorithms |
| 364 | +The combination is both reliable and flexible. |
| 365 | + |
| 366 | + |
341 | 367 | *Why are MCP tools needed when the LLM can reason, generate SQL, etc?* |
342 | 368 | LLMs are invaluable for tasks that involve ambiguity, reasoning, or natural language. |
343 | 369 | When compared to procedural code, however, they can be slow, expensive, non-deterministic, and sometimes produce unreliable results. |
|
0 commit comments