Skip to content
ImagineWorld

Transactional

node_idnode-book_ai-ready-postgresql-18_chapter-01-transactional
node_typechapter-node
schema_profileworld.chapter_node.v1
statusactive
entropyhigh
manifoldworld
domainimagineworld.net
authorityinforms
layercorpus
chapter_num1
chapter_titleTransactional
governed_byCORPUS
constitutional_citationCONSTITUTION
local graph

Transactional, Analytical, and AI Business Systems and Their Database Requirements

Section titled “Transactional, Analytical, and AI Business Systems and Their Database Requirements”

Databases are the backbone of modern digital infrastructure. They are at the heart of e-commerce sites, banking solutions, order management systems, social media, and healthcare operations. Email systems store messages in databases, and WWW search engines use them to index and rank content. Generative AI solutions leverage them to store and retrieve vast datasets for training and inference. High-performance application designs use in-memory databases to reduce latency. Mobile phones use local databases to store user preferences, recently dialled numbers, known Wi-Fi networks, and more. Almost all business systems rely on databases in one way or another. They serve as organized repositories for information, enabling the efficient storage and retrieval, as well as consistent management, of data.

The origin of databases can be traced back to the 1960s. They were initially only considered ways to store data in structured files using hierarchical and network navigation models. But the hierarchical and network databases turned out to be very rigid and difficult to maintain as they often encoded use case-driven navigation patterns into the data model. In the 1970s, the relational model emerged and provided the foundation for Oracle, Ingres, IBM Db2, SQL Server, MySQL, and PostgreSQL, offering greater flexibility and data integrity through structured relationships. The first specialty analytics solutions emerged at that time, too, such as Teradata, to address the increasing need to derive insights from data and to support more forward-looking, decision-oriented reporting for executives.

In the early 2000s, the explosion of data in volume and variety, driven by the rise of the internet and digital communication, led to the creation of NoSQL databases, such as HBase and Cassandra. They focused on fast ingestion and cost-effective storage of a wide variety of data formats, such as emails, documents, and Internet of Things (IoT) data, as well as scalability to handle massive, diverse datasets. The need for faster time to market and developer velocity created MongoDB, Couchbase, and other document databases offering flexible schemas and data models.

After 2010, many databases adopted the cloud as a new platform, and we saw a renewed interest in ACID compliance. At the same time, we saw PostgreSQL begin to add NoSQL and parallel query capabilities and to improve its analytics. Databases to support AI, especially generative AI, have been the dominating topic of the last few years, optimizing vector embeddings and real-time data processing.

Figure 1.1: History of databases

Your purchase includes a free PDF copy + code bundle

Why do we have multiple types of databases?

Section titled “Why do we have multiple types of databases?”

Not all database requirements are the same. Traditionally, we associated databases with ACID transactional workloads, where Atomicity (A), Consistency (C), Isolation (I), and Durability (D) were of primary importance to support transactional workloads such as credit card processing, order management, and human resources data.

As data began to become increasingly important to drive business decisions, and data volumes grew tremendously, a new class of databases that are focused on analytical processing emerged, where the priority is on working with very large volumes of data and answering complicated questions. At the same time, data-driven decision-making started to incorporate data in many other forms, not just tables. Documents, images, and data from IoT were added. These new requirements of high-volume, high-variety, and high-velocity data led to the introduction of specialized data warehouse and data lake solutions, which are less concerned with transactional integrity and more with answering complex requests that review very large amounts of data.

Finally, Artificial Intelligence (AI) entered the stage to derive new insights and generate completely new answers in ways that traditional transactional queries or analytics processes cannot handle. Semantic analysis, approximate nearest neighbour searches, multi-dimensional vectors, and embedding capabilities for AI encoding were required to address these needs. This led to the demand for specialized database capabilities.

Dedicated vector processing solutions appeared to be the ideal way to address this problem, but almost all other databases also started to introduce vector processing capabilities.

At the same time, PostgreSQL, an open source project that began almost 40 years ago, had become the most loved and one of the most widely adopted databases by developers worldwide. Several foresightful design decisions taken by Michael Stonebraker and his team have contributed to that success. Key among these was the decision to use an object-relational architecture that makes PostgreSQL inherently extensible, allowing it to act as a framework for new data types, operators, and functions, and to address new use cases.

This book describes how PostgreSQL, a.k.a. Postgres, stands the test of time and is evolving to meet, and often lead, the new data management challenges. The authors believe that PostgreSQL can handle the majority of transactional, analytical, and AI requirements that developers encounter in modern data-driven applications.

This book will show you how to do that!

How are transactional, analytical, and AI application requirements different?

Section titled “How are transactional, analytical, and AI application requirements different?”

Application requirements vary widely—whether it’s processing financial transactions, analyzing large volumes of data, or powering AI models. Transactional, analytical, and AI workloads each place distinct demands on database systems, from low latency and consistency to scalability and the need to scan large amounts of complex data. Read on to get a brief introduction to how each of these application types differs in its requirements.

Part 2, Creating Transactional Applications, Part 3, Creating Analytical Applications and Part 4, Using PostgreSQL as an AI Platform of this book dive into greater detail into these topics.

Databases for transactional systems focus on efficiently processing transactions in highly concurrent environments. The transactions tend to be short, and their execution must be ACID compliant, which we will explain using a simple three-statement example of moving money between two accounts and updating the activity log to create an audit of the transactions:

  1. Remove $100 from Marc’s account.
  2. Add $100 to Vibhor’s account.
  3. Update the activity log.

We will use this simple sequence of three operations to illustrate the four key properties of reliable transactions, commonly known as the ACID properties:

  • Atomic: A transaction can consist of many statements. Atomic means that either all statements are executed or none of them are. The atomic property requires that, in our example, all three statements are executed successfully, or none of them are. Either the $100 stays in Marc’s account and no log entry is made, or the money moves and a log entry is made.
  • Consistent: Transactions move the database from one valid state to another while maintaining all of the defined rules. In our example, this means that both accounts are updated immediately, and all constraints are validated, for example, account value > $0. Every user always sees a consistent picture of the database. If any constraint gets violated, all aspects of the transaction are immediately undone (rolled back).
  • Isolated: Multiple transactions can happen at the same time, and they don’t interfere with each other. Other users see the state either before the transaction or after the transaction—never in between. In our example, this means that other users see the state where the 100iseitherinMarc′saccountorinVibhor′saccount.Theycanneverseeastatewherethe100 is either in Marc's account or in Vibhor's account. They can never see a state where the 100 is in neither Marc’s nor Vibhor’s account. Transactional databases differentiate between different isolation levels: read uncommitted, read committed, repeatable read, and serializable.
  • Durable: Once committed, transactions persist even in the case of system failures. In our example, this means that even if the banking software were to crash right after it completed the third statement and received the commit acknowledgement, when it restarts, the $100 would be in Vibhor’s account, not in Marc’s account, and the activity log would show as updated.

ACID compliance is a must-have for any true transactional system. Part 2 of the book will go into greater detail on the ACID requirements, explain the notion of i solation l evels, and help you define transactions and pick the appropriate isolation level for your application.

Transactional systems also have strong operational and performance requirements, such as the following:

  • Data n ormalization: Information is organized to minimize redundancy and optimize data integrity. Database practices differentiate between multiple levels of normalization: First Normal Form (1NF), 2NF, 3NF, Boyce-Codd Normal Form (BCNF), and up to 6NF. Part 2 will go into greater detail and explain the advantages of normalization, as well as describing how to achieve these different levels.
  • Concurrency control: The system typically supports hundreds, if not thousands, of concurrent users and requests that must be handled in parallel while maintaining ACID compliance.
  • Indexing for transactions: Transactions primarily focus on a few uniquely identified records. Primary keys, foreign keys, and integrity constraints play a key role.
  • Backup and recovery: To meet the durability requirement, the system must be continuously backed up and be fully recoverable at any point in time.
  • High throughput and low latency: This refers to the ability to process many transactions per second through efficiency of processing and through parallel execution, and at the same time making sure that every single transaction completes quickly.
  • High- performance Input/Output (I / O): Transactional databases are very write-intensive, as every transaction must be written to persistent storage before it can become a committed transaction. This capability is needed to meet the ACID durability requirement.
  • Security and access control: This refers to role-based access control models that protect data from unauthorized access or modification. Auditing mechanisms are key to understanding who accessed data and what was changed.

Transactional systems typically store data in a tabular format, using a highly normalized, deduplicated data model to enable updates as quickly as possible. Recently, document formats have been integrated into transactional workloads, as many browsers and application development environments thrive on formats such as JSONB or BSON.

Where transactional workloads tend to work with a smaller subset of data, some of which may be modified as part of a transaction, analytical systems most often work with very large amounts of data that is mostly processed in a read-only manner. Analytical queries tend to be longer-running and often deal with complex aggregations of very large amounts of data. ACID compliance and transactional mechanisms are often of secondary importance; the efficiency of storing and processing large data volumes and distributing complex requests across multiple datasets is paramount.

Recently, the addition of new, highly variable data formats, such as text and images, has led to the definition of data lakes, which incorporate traditional tabular data structures with columnar file formats such as Parquet and open table formats such as Apache Iceberg. When data lakes and data warehouses are integrated, they form what is known as a lakehouse.

Key performance and operational requirements for analytical systems include the following:

  • High performance for complex analytical queries on large datasets: Analytical queries evaluate large datasets, sometimes many terabytes, to derive insights. Data must be loaded from storage efficiently, which often involves compression and decompression to reduce network and I/O overhead, and columnar storage to load just the columns of interest instead of the whole row and achieve optimal data compression.
  • Effective i ndexing for analytics: Analytics operations often work on ranges of data. Indexes must facilitate the quick and cost-effective identification of large datasets.
  • Efficient data ingestion: Analytics systems often act as the integration point for many business systems. Efficient E xtract- T ransform- L oad (ETL) or E xtract- L oad- T ransform (ELT), streaming, data copying, and virtual data integration capabilities are essential.
  • Analytic s -specific data formats: Analytics requests benefit from pre-computed results that are accessed frequently (e.g., daily averages), and denormalized data representations that improve I/O and simplify query definitions by reducing normalization levels and adding data duplicates. The most frequently used formats are CUBES, STARS, and ROLLUPS.
  • Efficient data transformation into denormalized analytic-specific data formats: Normalized data must be quickly transformed into analytics formats to avoid any lag between the transactional data that was just ingested and its analytical availability.
  • Comprehensive support for **structured,****semi-structured,**and unstructured data: Classical data warehouses tend to work on tabular data that has been denormalized, and they integrate partly pre-computed aggregates. Cubes, rollups, and materialized views are often used to simplify and accelerate data access. Semi-structured (JSON and other document formats) and unstructured (images, texts, PDFs, etc.) data are increasingly part of the analytical process. Document access, for example, JSON path, text search, and image analysis, is increasingly important.
  • Cost-effective **storage,**including storage tiering: Analytics systems can grow to hundreds of terabytes and even petabytes. Storage that is optimized for high write performance in transactional systems, such as SSDs, is usually too expensive and not scalable enough. Object storage solutions, such as S3, are preferred for data lakes.
  • Robust fault tolerance and reliability: Just like transactional systems, analytics systems are considered mission-critical. When analytics is unavailable, the business waits. As organizations rely more on near-real-time dashboards and operational reporting, H igh A vailability (HA) and D isaster R ecovery (DR) capabilities are needed to minimize downtime.
  • Rigorous security and **governance,**including auditing: Just like transactional systems, analytical systems require security, governance, and auditing. Because of the amount of data, security can be even more important.

AI systems operate in two major modes: training mode, where they ingest large amounts of information to create LLMs, and inference mode, where they use the LLMs to analyze data, create embeddings for knowledge bases and specific requests, and generate new insights. In this book, we focus on the database capabilities needed to support the inference mode, the operational phase where AI models are applied to real-world data.

In inference mode, the database focuses on working with embeddings, which represent the semantic encoding of a knowledge document or a request. This includes storing the embeddings as multi-dimensional vectors, associating the embeddings with the original knowledge content, indexing the embeddings, and retrieving them using A pproximate N earest N eighbor (ANN) semantic searches. This process is crucial for understanding context and relevance within vast datasets.

The key requirements for AI databases are designed to support high-performance, scalable, and reliable inference operations:

  • Efficient storage of embeddings: Embeddings are stored as highly dimensional vectors. These vectors, which can have over 1,000 dimensions, must be stored efficiently, and fast C reate/ R ead/ U pdate/ D elete (CRUD) operations are a requirement. This necessitates a specialized database structure optimized for vector data.
  • Efficient and effective indexing of embeddings: Retrieving knowledge content corresponds to a nearest neighbor search in the multi-dimensional space defined by the vectors. Indexing needs to be efficient and effective to identify the best possible matches as quickly as possible: great recall at high throughput. Multiple indexing strategies are needed, depending on whether one wants an exact match or an approximate match. Incremental index adjustments versus reindexing when new knowledge is added also needs to be considered. The choice of indexing strategy significantly impacts search performance and accuracy. Part 4 will discuss AI indexing options.
  • H igh - speed queries: Queries in the multi-dimensional vector space find the ANNs and return information about the original knowledge content. Real-time responsiveness is paramount for interactive AI applications.
  • Fault tolerance and reliability: Just like transactional and analytical systems, AI systems are mission-critical. They require continuous availability and data integrity (that is, protection against data corruption and loss) to ensure uninterrupted service.
  • Security and **governance,**including auditing: Just like transactional systems and analytical systems, AI databases require security, governance, and auditing. Robust access controls, data privacy measures, and auditable logs are essential.
  • Cost-effective **storage,**including storage tiering: AI databases store the embeddings in a high-performance tabular-oriented environment with performance requirements that are like those of transactional systems. However, much of the raw knowledge content (documents, pictures, etc.) that is the foundation for the embeddings is stored on cost-effective and slower storage architectures such as object stores. This tiered approach balances performance and storage costs.

Transactional, analytical, and AI databases have many shared requirements. They all need security, governance, and auditing. The same is true for high availability and reliability.

While transactional databases typically require high concurrency for update transactions, analytics and AI solutions that are an integrated part of a modern business system also need to support many concurrent users and queries.

It is important to keep in mind that there is no hard boundary between analytical and transactional systems. Most transactional systems tend to include reports and dashboards, which are sometimes called tactical analytics. Within the analytics space, there is a wide range of use cases, ranging from simple analytics (“Show me which T-shirt sold well last Tuesday morning in the Oklahoma store”) to more complex queries (“Use the 2024 point-of-sale data from all US stores to identify the top 10 products that were on sale and had the highest pull through for high-margin groceries”). This spectrum highlights the diverse analytical needs, from operational insights to strategic business intelligence.

In this book, we focus on key differences in data types, data organization, I/O handling, indexing strategies, and querying. Understanding these distinctions is important for selecting and optimizing the right databases for specific workloads.

The following table summarizes the core differences in data handling across transactional, analytical, and AI workloads.

WorkloadMajor data typeData organizationI / OIndexingQuerying
TransactionsTabular, row-orientedNormalizedWrite-intensive, random access to small datasetsIdentification of unique recordsShort queries, low latency
AnalyticsTabular, row- and column-orientedDenormalizedRead-intensive, large data volumes, leverages compressionIdentification of data ranges and large datasetsComplex queries, higher latency
AITabular, row-oriented with focus on multi-dimensional vectorsNormalizedRead-intensive in most transactions, update transactions are very index write-intensiveIdentification of exact neighbor and nearest neighbor in multi-dimensional spaceShort queries, low latency

Table 1.1: Core data handling differences in transactional, analytical, and AI workloads

Historical reasons for specialized solutions

Section titled “Historical reasons for specialized solutions”

Many database products are specialized for one data type, or one data access and I/O method. Traditionally, transactional database systems such as Oracle, MySQL, and PostgreSQL used a row-based approach as that is best suited for updating or inserting a smaller number of records. But it is less suitable for working with very large datasets or data ranges in analytical applications.

Analytics-specific databases, such as Snowflake, BigQuery, Redshift, and Apache Parquet, leverage a columnar approach as it significantly improves read performance for denormalized data, allows for columnar compression, and works well with large datasets—but it is less suitable for transaction processing. Similarly, specialized AI databases, such as Weaviate and Pinecone, are designed solely for vector processing to support ANN search.

Specialized solutions are relevant as they initially outperform generalists, especially in very large or demanding datasets. Also, specialty solutions can often be brought to market faster. However, this often comes at the cost of increased complexity in managing multiple data platforms.

Transactional and analytics databases are continuously adding features to extend their capabilities into the adjacent use cases. For example, MySQL and Snowflake have added vector capabilities to support AI workloads.

However, there are databases such as PostgreSQL that were designed from the beginning to allow for the integration of new data types—such as GIS (V1 release in 2005), key-value pair (PostgreSQL 8.3; 2008), JSONB (PostgreSQL 9.4; 2024), and vectors (pgVector V0.5 in 2023)—as well as databases designed for great extensibility—such as Greenplum (2005)and TimescaleDB (2017)—and other offerings, such as EDB Bluefin (2021) for append-only data loads, Citus CStore for columnar storage (2015), and pg_duckdb for access to open table formats (2020). These have the underlying architecture to provide a unified platform that supports the majority of transactional, analytical, and AI workloads.

Multiple specialty solutions are an architectural challenge

Section titled “Multiple specialty solutions are an architectural challenge”

It is tempting to use a best-of-breed approach and create a hybrid data architecture that uses best of breed for transactions (e.g., Postgres), analytics (e.g., Databricks), and AI (e.g., Pinecone), and establishes data pipelines that keep the specialized databases in sync.

Figure 1.2: Integrating multiple specialty solutions through external and internal data pipelines

The data pipeline architecture allows us to take advantage of the strengths of different database solutions, but it also has significant disadvantages:

  • Storing data in multiple places drives up costs and complicates operations such as backup and recovery. It can also lead to compliance issues due to data duplication. Data can also easily get out of sync, leading to inconsistency and potential data integrity problems.
  • Simple data pipelines use a batch copy approach, which leads to delays in data availability (e.g., the data warehouse is “mostly” yesterday’s data) and reduces the business value (e.g., we need to wait until tomorrow to assess this morning’s sales velocity). This latency is not compatible with real-time decision-making requirements.
  • When solutions mature, the batch copy approach becomes unworkable as the data volume grows, and the batch window becomes prohibitively long. This often results in missed service-level agreements and operational bottlenecks.
  • Pipelines that use an incremental Change Data Capture (CDC) approach are extremely complex, especially when multiple systems with different data formatting requirements need to stay in sync. The development, maintenance, and monitoring of such pipelines demand significant resources and expertise.
  • The application developers must be familiar with multiple query languages: SQL for Postgres, Spark SQL for Databricks, and Query API for Pinecone. This increases developer onboarding time and reduces overall productivity.
  • Operators must manage and coordinate multiple software maintenance processes, CVEs, and upgrade cycles.

These challenges underscore the need for a more integrated and versatile data management approach. Fortunately, PostgreSQL has emerged as a solution that can cover many of the requirements outlined previously. This has contributed to a tremendous adoption of PostgreSQL among developers and DBAs. PostgreSQL has become the #1 choice for the world’s most demanding applications in financial services, manufacturing, retail, social networks, AI, and government.

The steady rise of PostgreSQL in industry adoption can be clearly seen in the Stack Overflow Developer Survey rankings shown below.

YearRank% Developers U sing PostgresKey Competitors
2025#155.6%MySQL (40.5%), SQLite (37.5%)
2024#148.7%MySQL (40.3%), SQLite (33.1%)
2023#147%MySQL (47%), SQLite (32%)
2022#246%MySQL (47%), SQLite (32%)
2021#240%MySQL (51%), SQLite (32%)
2020#238%MySQL (55%), SQLite (32%)
2019#234%MySQL (58%), SQLite (32%)
2018#332%MySQL (58%), SQL Server (36%)

Table 1.2: PostgreSQL developer popularity in Stack Overflow Developer Surveys (2018–2025)

This chapter provided an overview of the key database workloads: transactional, analytical, and AI. It described their requirements and demonstrated how PostgreSQL has evolved over the last 10+ years to be able to cover many of these needs.

The next chapter will give a brief overview of the history of Postgres, including how its transactional, analytical, and AI features have evolved in the last few years. It will also describe why it has become the #1 choice for modern business applications that leverage transactions, analytics, and AI.