Bring Your Own Database

Store your document data in your own PostgreSQL or BigQuery database for full data sovereignty.

Ragnerock can store your document data in a database you control instead of the default managed database. Embeddings, user accounts, and platform metadata remain in Ragnerock’s infrastructure, but documents, chunks, pages, and annotations live in your database.

What Moves to Your Database

Your DatabaseRagnerock Database
DocumentAccount, User, Project, Team
DocumentChunkDocumentGroup
DocumentPageDocumentChunkEmbedding
AnnotationRootOperator, Workflow
AnnotationValueNotebook, Cell
UsageEvent, AccountQuota

Embeddings stay in Ragnerock because they require a specialized vector database for similarity search. All other document-related data moves to your database, giving you full ownership and direct query access.

Supported Providers

ProviderStatusNotes
PostgreSQLGAFull support including optional schema isolation
BigQueryGANo foreign key constraints; UUIDs stored as 32-character hex strings; JSON stored as STRING
SnowflakeAvailableOrganization-account identifier; a warehouse is required for writes
DatabricksComing soon-
Db2Self-hostedDb2 for Linux, Unix and Windows 11.5 or later. Needs the Db2 extension. See Db2 below

Setup

Configuration follows a three-step workflow: create, initialize, activate.

Navigate to Settings > Database to access the database configuration page. Click Add Database to start the setup wizard.

The database configuration settings page showing the Add Database button

1. Create a Configuration

Select PostgreSQL or BigQuery as the provider type, then fill in your connection details.

PostgreSQL

Enter your PostgreSQL connection string in the format:

postgresql://user:password@host:5432/ragnerock_data

Optionally specify a schema name for schema isolation (e.g., ragnerock). The connection string supports standard PostgreSQL parameters including sslmode, sslrootcert, and connect_timeout:

postgresql://user:password@host:5432/dbname?sslmode=verify-full&sslrootcert=/path/to/ca.pem

BigQuery

Enter your GCP project ID, dataset name, and upload your service account credentials (JSON key file). Optionally specify a dataset location (auto-detected if omitted).

The service account needs bigquery.dataEditor and bigquery.jobUser roles.

For Db2, which needs some setup on the database side first, see Db2 below.

2. Initialize the Schema

After creating the configuration, click Initialize to create the required tables (Document, DocumentChunk, DocumentPage, AnnotationRoot, AnnotationValue) in your database. Tables are created with IF NOT EXISTS, so initialization is idempotent. You can safely run it multiple times.

3. Activate

Toggle the configuration to Active to start using it. Only one database configuration can be active per account. Activating a new configuration automatically deactivates any existing one. From this point on, all new document data is written to your database.

Db2

Ragnerock can keep its data in IBM Db2 for Linux, Unix and Windows, version 11.5 or later. We test against Db2 12.1. Db2 for z/OS and Db2 for i aren’t supported, and Initialize refuses them.

Db2 is only available on self-hosted deployments. Ragnerock doesn’t ship IBM’s Db2 driver in its images, so you build Db2-enabled images yourself with the Dockerfile we publish; Self-Hosted Extensions walks through it. Until those images are deployed, Db2 shows up in the provider list as unavailable, with the reason next to it. Hosted Ragnerock doesn’t offer Db2.

Connection string

A Db2 connection string always says how Ragnerock signs in, with the auth option. There are four forms:

db2://user:password@host:50001/database?auth=password
db2://iam:API_KEY@host:50001/database?auth=iam&iam_endpoint=public
db2://app%40EXAMPLE.COM@host:50001/database?auth=kerberos&service_principal=db2%2Fdb2.example.com%40EXAMPLE.COM
db2://@host:50001/database?auth=certificate

The form in Settings > Database has separate fields for each method and builds the string for you, including the escaping. If you write it yourself:

  • The port is required. Db2’s usual TLS port is 50001.
  • Kerberos principals contain @, so percent-encode them (%40, and %2F for a /).
  • The options are auth, security, iam_endpoint, service_principal, schema and tablespace. Anything else, or the same option twice, is refused with a message naming it.
  • security is ssl (the default) or none. IAM and client certificates only work with ssl. Use none only for a test database on a network you trust.
  • schema names the schema Ragnerock’s tables go in. The Schema Name field under Advanced Settings overrides it. Db2 folds unquoted names to upper case, so ragnerock and RAGNEROCK are the same schema.
  • tablespace names the tablespace the tables are created in. See Page sizes.
  • Db2 user names and passwords can’t contain a semicolon. Db2’s driver reads it as the end of the value, and there’s no way to escape it, so a password with ; in it is refused. Change the password.

The masked hint Ragnerock shows for a saved config keeps the user, host, database and options and drops the password or API key.

Signing in

MethodauthWhat you provide
User and passwordpasswordA Db2 user and its password, in the URL
IBM Cloud API keyiamThe literal user iam, the API key as the password, and optionally iam_endpoint
KerberoskerberosThe client principal as the user, the server’s service_principal, and a keytab for the client principal, uploaded
Client certificatecertificateNo user or password. The client certificate and its private key, uploaded

Uploaded files (the keytab, the client certificate and key, and a CA certificate) are encrypted with the rest of the config and never returned by the API. Each file can be at most 8 KB.

User and password

Db2 checks passwords against the operating system or LDAP, not against a user table in the database, so the user has to exist there first. Then grant it what it needs (see Grants).

IBM Cloud API key

For Db2 on Cloud and Db2 Warehouse on Cloud. Ragnerock exchanges the API key for an IAM access token at IBM Cloud IAM and signs in with the token. The key itself never goes to the database. Tokens last about an hour; pooled connections are replaced before theirs runs out.

iam_endpoint picks where the key is exchanged. Ragnerock only sends the key to one of these hosts:

iam_endpointHost
public (default)iam.cloud.ibm.com
privateprivate.iam.cloud.ibm.com
private-us-southprivate.us-south.iam.cloud.ibm.com
private-us-eastprivate.us-east.iam.cloud.ibm.com
private-ca-torprivate.ca-tor.iam.cloud.ibm.com
private-br-saoprivate.br-sao.iam.cloud.ibm.com
private-eu-gbprivate.eu-gb.iam.cloud.ibm.com
private-eu-deprivate.eu-de.iam.cloud.ibm.com
private-eu-esprivate.eu-es.iam.cloud.ibm.com
private-jp-tokprivate.jp-tok.iam.cloud.ibm.com
private-jp-osaprivate.jp-osa.iam.cloud.ibm.com
private-au-sydprivate.au-syd.iam.cloud.ibm.com

Private endpoints only resolve on IBM Cloud’s private network, so pick one only if your Ragnerock deployment runs there or is connected to it. If it can’t reach the host, the connection fails with “Couldn’t reach the IBM Cloud private IAM endpoint … Private endpoints only work from inside IBM Cloud’s private network.” For a data database, db-service makes the token request, so db-service’s network needs a route to the host and DNS that resolves it.

Kerberos

Each config brings its own client principal and a keytab for it. Ragnerock never uses a ticket or keytab that belongs to the deployment, so one account can’t connect as another’s identity. When a connection opens, Ragnerock gets the principal’s credentials from the keytab into an in-memory credential cache that belongs to that config, and gets new ones shortly before they expire. The keytab is only on disk, readable by the service alone, for the moment that takes.

service_principal is the Db2 server’s own principal, usually the instance owner with the server’s host name, for example db2inst1/db2.example.com@EXAMPLE.COM. It is required, so Ragnerock never has to guess it from a DNS lookup.

The Kerberos servers (KDCs) for each realm come from the deployment’s krb5.conf, which your administrator writes and mounts into the Db2 images. A config can’t name its own KDC. If a principal’s realm isn’t in that file, the connection fails and tells you to ask your administrator to add it. Self-Hosted Extensions covers the file and how to mount it. Kerberos also needs images built with the Kerberos option; without it, the Kerberos choice is shown as unavailable.

Make the keytab on the KDC, for example with MIT Kerberos:

kadmin -q "ktadd -k ragnerock.keytab ragnerock@EXAMPLE.COM"

Writing a keytab this way gives the principal a new key, so do it once and upload that file. If the key is rotated later, upload the new keytab.

On the Db2 server, Kerberos has to be enabled for remote clients. With the instance owner:

db2 update dbm cfg using SRVCON_GSSPLUGIN_LIST IBMkrb5 SRVCON_AUTH KRB_SERVER_ENCRYPT
db2stop
db2start

KRB_SERVER_ENCRYPT accepts Kerberos and also passwords; use KERBEROS to accept Kerberos only. The server needs its own keytab for the service principal (by default /etc/krb5.keytab, readable by the instance owner) and a krb5.conf that knows the realm. Db2 maps a principal to an authorization ID by its name, so ragnerock@EXAMPLE.COM connects as RAGNEROCK, and that’s the ID your grants name.

Kerberos authenticates without TLS, but use TLS anyway: without it the data itself isn’t encrypted.

Client certificate

With auth=certificate, Ragnerock signs in with a TLS client certificate instead of a user name: it turns the uploaded certificate (with its chain) and private key into a keystore for the Db2 driver, protected by a password generated for that connection, and the server takes the authorization ID from the certificate. Upload the key’s passphrase too if the key is encrypted. A certificate that has already expired is refused when you save.

The server has to accept client certificates as a login and map the certificate to an authorization ID. We have not been able to confirm that with a Db2 for Linux, Unix and Windows server: Db2 12.1 in our tests doesn’t take a client certificate as a login. Check with IBM’s documentation for your server before relying on this method, and use a password, an API key or Kerberos if your server doesn’t support it.

TLS

Connections always use TLS. security=none is refused unless the deployment sets DB2_ALLOW_INSECURE_TLS, which is meant for local development only. To trust a server certificate that wasn’t issued by a public certificate authority, which is usual for a self-managed server, upload the CA certificate (PEM) under CA certificate. Without one, Ragnerock trusts the common public certificate authorities, which covers Db2 on Cloud.

Setting up TLS on the server is a Db2 task: a GSKit keystore holding the server certificate, SSL_SVR_KEYDB, SSL_SVR_STASH, SSL_SVR_LABEL and SSL_SVCENAME in the instance configuration, and SSL in DB2COMM.

Page sizes

Db2 refuses a table whose rows could be wider than the tablespace’s page. Ragnerock’s widest tables need a page of at least 16 KB, and the query layer’s sorts need a system temporary tablespace with 32 KB pages. A new Db2 database has neither: its default page size is 4 KB.

As the instance owner or another user with SYSCTRL, create a bufferpool for each page size, a tablespace for Ragnerock’s tables and a system temporary tablespace:

CREATE BUFFERPOOL BP16K IMMEDIATE SIZE 2000 PAGESIZE 16K;
CREATE BUFFERPOOL BP32K IMMEDIATE SIZE 1000 PAGESIZE 32K;

CREATE LARGE TABLESPACE RAGNEROCK_DATA PAGESIZE 16K
  MANAGED BY AUTOMATIC STORAGE BUFFERPOOL BP16K;

CREATE SYSTEM TEMPORARY TABLESPACE TEMP32K PAGESIZE 32K
  MANAGED BY AUTOMATIC STORAGE BUFFERPOOL BP32K;

Size the bufferpools for your workload; the numbers above are pages and only a starting point. A tablespace with 32 KB pages also works for the tables.

Then either name the tablespace in the connection string (tablespace=RAGNEROCK_DATA) or leave it out and let Db2 pick a tablespace the user may use whose pages are big enough. Initialize checks both requirements and tells you which one is missing and what page size it needs. Without the system temporary tablespace, queries fail with SQL1585N.

Grants

Create the schema first; Ragnerock creates tables, not schemas. A user that owns the schema can already create and drop tables in it. Otherwise:

CREATE SCHEMA RAGNEROCK;
GRANT CONNECT ON DATABASE TO USER RGNK_APP;
GRANT CREATETAB ON DATABASE TO USER RGNK_APP;
GRANT CREATEIN, ALTERIN, DROPIN ON SCHEMA RAGNEROCK TO USER RGNK_APP;
GRANT USE OF TABLESPACE RAGNEROCK_DATA TO USER RGNK_APP;

Ragnerock creates its own tables, indexes and foreign keys, and owns them, so it needs nothing on individual tables. Initialize creates and drops a scratch table, inside a transaction it rolls back, to check the user can create tables in the schema. It reads SYSCAT.TABLESPACES to check page sizes, which every user can read unless you’ve revoked it; if you have, that check is skipped and a page that’s too small shows up when the tables are created. Nothing reads the SYSIBMADM views.

How the data is stored

Ragnerock typeDb2Querying it yourself
IdsCHAR(36), dashed UUID textPlain string comparison
JSON columnsCLOB(2G) holding JSON textJSON_VALUE(generation_metadata, '$.model')
TextCLOB(2G)CLOB can’t be used in GROUP BY, ORDER BY or DISTINCT; cast to VARCHAR first
BooleansBOOLEANTRUE and FALSE
TimestampsTIMESTAMP, UTC wall timeSee Time zone

Db2 normally keeps a CLOB outside the row, which makes every read a separate fetch. Ragnerock gives the columns it reads most an inline length, so values up to that size are stored in the row with everything else and longer ones go to LOB storage as usual:

TableColumnInline length (bytes)
annotationvaluevalue1,024
annotationrootgeneration_metadata1,024
documentchunkcontent4,096
documentpagecontent8,192
documentmetadataval512
tabularrowdata4,096
tabularrowcontent4,096
tabularsheetcolumns2,048
cellcontent4,096

The lengths are in bytes and the database stores UTF-8, so text in non-Latin scripts fits fewer characters. They’re fixed when the tables are created; Db2 can only make an inline length larger, and only with a table reorganization.

Use a database created without Oracle compatibility (varchar2_compat off, which is Db2’s default). With it on, Db2 stores empty strings as NULL, and some of Ragnerock’s text columns don’t allow NULL.

Time zone

Db2 has no time-zone-aware timestamp type and no per-session time zone. Ragnerock stores every timestamp as UTC wall time and writes the values itself, so what it stores is correct whatever the server’s time zone. Column defaults are different: DEFAULT CURRENT TIMESTAMP uses the server’s local time, so a row you insert by hand without a timestamp gets local time. Run the Db2 server in UTC to keep everything consistent.

Things to know

  • No statement timeout. Db2 doesn’t honour a connection-wide query timeout, so queries against the data database aren’t stopped by Ragnerock after a time limit. Lock waits are bounded: each connection sets CURRENT LOCK TIMEOUT to 30 seconds, so a blocked write fails instead of waiting forever (Db2’s default).
  • Long JSON values in filters. When a query filters or sorts on a value read out of tabular data or document metadata, values longer than 4,000 bytes read as NULL. The stored data is unaffected.
  • Keys and constraints are enforced. Primary keys and foreign keys are real constraints on Db2, as on PostgreSQL and Oracle.
  • Statements are transactional. Db2 runs DDL inside transactions, so a migration that fails part way rolls back cleanly.
  • High availability. The data database connection keeps the Db2 driver’s defaults, so automatic client reroute to an HADR standby works as it does for your other clients.
  • Upgrades. The Db2 images have to be rebuilt for every Ragnerock release. If they aren’t, Db2 is shown as unavailable with “The Db2 images are from a different Ragnerock version than the rest of this deployment. Rebuild them for this version.”
  • Slightly slower SQL parsing. The Db2 images run the pure-Python build of the SQL parser Ragnerock uses, because IBM’s Db2 dialect can’t run on the compiled one. You’re unlikely to notice.

Using with Bring Your Own Blob Storage

BYODB and BYOBS (Bring Your Own Blob Storage) are independent features that complement each other. BYODB controls where structured document data is stored (database rows), while BYOBS controls where raw files are stored (object storage). Use both together for full data sovereignty.

Consistency Model

Ragnerock uses an eventual consistency model across the two databases. When a document is processed:

  1. Chunks are written to your database first
  2. Embeddings are generated and written to Ragnerock’s database

Each chunk tracks its embedding state (PENDING, COMPLETE, FAILED). A background reconciliation job retries any failed embeddings automatically. During the window between chunk creation and embedding completion, the chunk exists in your database but is not yet searchable via semantic search.

Managing Configurations

In the Database settings page, all your configurations are listed with their provider type, connection hint, and status (active, inactive, or uninitialized). From this page you can:

OperationDescription
View detailsClick a configuration to see its full settings and masked connection string
Update connectionEdit the connection string or credentials. Requires re-initialization and re-activation.
DeactivateToggle to inactive to revert to Ragnerock’s default database
Health checkClick Check Health to test connectivity and view status
DeleteRemove a configuration (must deactivate first)

Security

Encryption: Connection strings and BigQuery credentials are encrypted at rest using envelope encryption. A per-configuration data encryption key (DEK) encrypts the credential, and the DEK itself is encrypted with a key encryption key (KEK) stored in a hardware-backed key management service.

Access control: Only account owners can create, update, initialize, activate, or delete database configurations. Other team members can view configurations with masked connection strings and check health status.

Connection masking: Connection strings are never returned in full. Only a masked hint is displayed (e.g., postgresql://user:***@host:5432/db).

Auto-deactivation: If Ragnerock fails to connect to your database 5 consecutive times, the configuration is automatically deactivated to prevent data loss. Resolve the connectivity issue and re-activate to resume.

Next Steps