Thoughts about Postgres and AI

This is a follow-up to the discussions and presentations at the AI Summit at PGConf.EU 2025 – the largest Postgres user, hacker, developer, and open-source enthusiast conference in the world.

AI has become an important topic for Postgres users and developers alike. Many ideas are being floated, starting with using AI (and Machine Learning) to make Postgres itself more efficient and easier to use. Other concepts plan to use Postgres as a data platform to feed AI/ML engines. A third approach sees AI as just another use case for Postgres.

In the next few paragraphs, I will try to shed more light on these developments, and I will do my best to explain why I believe they are highly interconnected – and will all become an important part of the Postgres ecosystem.

AI for Postgres

Postgres, just like any other enterprise-level database, can be complex to use and operate. Making Postgres easier has been a mainstream effort in the community: one-click installers, index advisors, DBA tools, pg_upgrade, configuration advisors, and statistics interfaces have all pursued this goal. Historically, many of them, such as the index advisors or the configuration advisors, were based on hardcoded heuristics. Rules, like “Set shared_buffers = LEAST(RAM/2, 10GB);”, or “SET autovacuum_max_workers = 5;”, which are based on experience, have become hard-coded guidelines in many Postgres templates and installation processes.

Newer efforts use AI and machine learning to combine these experiential values with data collected in the specific database and workload, and adjust them to the actual workload, hardware, network, and query pattern. Examples here are the now-defunct Ottertune and the Danish company DBtune – a thriving Postgres optimization company founded by a Professor from Lund University and Stanford University.

While current efforts focus on tuning general database parameters, schema tuning, table optimization, query tuning, and index tuning are not far down the road. Both aspects of AI for Postgres are becoming increasingly important as Postgres adoption grows, and more and more non-experts start using Postgres. Vibe coding tools, such as Replit, that automatically generate databases without any human intervention, will make ‘AI for Postgres’ (actually ‘AI for Postgres Dummies’) even more important.

Another angle on this is the creation of DBA agents that can plug into a Model Context Protocol (MCP) architecture and be part of agentic processes that require database services. Such agents could follow complex playbooks that are a sequence of steps that the AI agent (or a human agent) can follow to detect, diagnose, and fix issues in a Postgres database.

Postgres for AI

There is no AI without data, and the outcomes of AI-driven processes are highly dependent on the quality of the data. Using the world’s most successful database as a way to store and manage the data that is used for training the AI engines, for fine-tuning existing LLMs, or to provide the context for RAG-type processes is an obvious next step.OpenAI is certainly showing the way on how one of the leading AI companies is using Postgres!

It’s also relevant to consider that data stored in relational databases tends to be of higher quality. Usually, it reflects business transactions, actual customer definitions, real product descriptions, and accurate prices. Using more reliable data would help reduce hallucinations, or GiGo (Garbage in, Garbage out).

However, there is a challenge: Much of the training input for LLMs is unstructured data (text, PDF, images, video, etc.) that is stored outside of transactional databases on object stores or network drives.

While Postgres is prodgeously polymorphic and can handle GIS, JSONB, and (limited) textual data, and has shown that it can handle 100TB+ of active data (see Adyen’s report from five years ago, Architecture in Motion or the recent Podcast To 100TB, and beyond!), both the volume and the storage cost currently make it challenging to use Postgres as a repository for AI. New approaches, such as DuckDB, that handle open table formats (OTF) such as Iceberg and Parquet, as a Postgres extension, may address this issue.

Postgres with AI

This is the area that gets most attention today: can we run AI processing inside the database, right next to the data? Can we integrate SQL processing with AI searching, generation, or even decision-making?

pgVector, as a technology to enable approximate nearest neighbor (ANN) searches, is at the heart of this discussion. Innovations, such as Scalable Nearest Neighbors (SaNN) from AlloyDB,  DiskANN from Microsoft, or RaBitQ IVF (see T. Steinbach’s contribution at the Postgres AI Summit), show that the initial scalability concerns are being addressed.

But there are other opportunities too. Today, Postgres’ processes focus on the use of the CPU don’t natively take advantage of potentially available GPUs as other specialized vector systems, such as Milvus do. This could accelerate Postgres in several AI-related areas:

  • Index (re)generation for high-dimensional vectors could be significantly accelerated. This will be very important when vector computations are applied to tables that participate in transactions, and the underlying data changes frequently.
  • Model Serving – which means deploying embedding generation models or large language models locally and running the corresponding processes locally instead of accessing a cloud API, with all of the associated cost, privacy, and latency concerns.

Some proprietary forks, such as EDB’s Postgres AI, announced native GPU acceleration.

How do they all play together?

The three aspects of AI are highly interconnected. In fact, I believe that we need to address all three vertices to achieve a productive symbiosis of AI and Postgres.

AI for Postgres needs Postgres with AI

AI for Postgres needs AI and ML engines that use Postgres-specific models in a PII-protected setting. General-purpose models are of limited use.

  1. Data quality issues. LLMs are trained on data available on the internet, and there is no assurance that the data used to train the model is accurate or was not generated by AI itself (AI Model Collapse).
  2. Lack of public training materials. There is a limited set of generally available high-quality material dealing with topics like schema design, table structure optimization, query optimization, and other in-depth Postgres topics.
  3. Privacy, confidentiality, and compliance issues. Once we go beyond general database server parameter tuning, the AI and ML components need to inspect the data model and the database logs – which will invariably expose proprietary data and potentially PII regulated under GDPR and other rules.

Thus, for ‘AI for Postgres’ to work, the AI engine must be integrated into Postgres – we need Postgres with AI in order for this to come to fruition.

Postgres with AI needs Postgres for AI

AI processing inside the database (or on a closely co-located separate process) needs to have access to training materials to generate or tune the model, or, in the case of RAG processing, to define the context of the AI request. For ML processes that learn about the behavior of a specific database, the ML process needs access to logs and statistics – which should not be stored on a transaction-focused expensive storage model and do not benefit from Postgres’ consistency checking abilities.

Ideally, they are stored on object stores or other low-cost models and accessed as needed in a read-only manner.

Postgres for AI needs AI for Postgres

Postgres for AI will need to extend Postgres’ polymorphic capabilities and has to integrate new storage models for the open data formats. This will further increase design and operational complexity. While I am confident that the Postgres planner can be adapted to the needs of the new storage models, the Postgres developer and user will be confronted with increasingly challenging decisions, for example, what data to store in OTF, when to migrate data from Postgres core storage to OTF, and how to model data on OTF for optimal performance. AI for Postgres will help address these questions.

Conclusion

AI is here to stay (duh!), and Postgres will benefit from it and play a major role in the use of AI in business systems. While there are different dimensions to the opportunity, they are highly intertwined and cannot (successfully) be tackled separately, IMHO.

Acknowledgements

Thank you to Ellyne Phneah, Gülçin Yıldırım Jelínek, and Torsten Steinbach for organizing the AI Summit at PGConf.EU. A lot of great insights. Please do it again.

Vibhor Kumar provided good feedback on an early draft of this post.