C3 AI Documentation Home

PostgreSQL Database

PostgreSQL is a relational database. The C3 Agentic AI Platform uses PostgreSQL as its SQL store in shared environments and in single node environments with a shared database. For what a shared database means for a single node environment, see the section Default databases in Specify a KV Store. The platform stores an entity Type in the SQL store unless the Type's @db annotation names another datastore.

When the platform uses PostgreSQL

The platform persists data in two kinds of datastore: a SQL store for relational data, and a key-value (KV) store. Your environment configuration decides which database backs the SQL store:

EnvironmentSQL store database
Single node environment (SNE)H2, unless the environment is configured to use PostgreSQL
SNE with a shared databasePostgreSQL
Shared environment (SE)PostgreSQL

H2 is a separate database that the platform runs in PostgreSQL compatibility mode. H2 suits testing and single node environments.

PostgreSQL is ACID-compliant: its transactions are atomic, consistent, isolated, and durable.

Choose PostgreSQL or a KV store

For each entity Type, you choose where the platform stores its data:

  • PostgreSQL (the default SQL store): Keep the default for entity Types that need relational queries, such as filters and references between Types. The Type needs no annotation.
  • KV store: Add @db(datastore='kv') to an entity Type to store it in the default KV store of the environment.

To choose among the KV store options, see Specify a KV Store.

PostgreSQL features that you use through the platform:

  • Indexes: Declare indexes on an entity Type with the index and unique fields of the @db annotation. For index types and best practices in the platform, see Database Indexes. For how PostgreSQL indexes work, see the PostgreSQL Indexes documentation.
  • Locks: PostgreSQL supports table-level locks. For how table-level locks work, see the PostgreSQL LOCK documentation.
  • Vector search: The platform supports the pgvector extension, which stores vector embeddings in PostgreSQL and searches them by similarity. See Vector Store.

See also

Was this page helpful?