Repository navigation
Data Architecture
This page is the entry to the data documentation of KingresDB. It shows where data lives, how it moves, and which page describes each part. Everything is taken from the SQL scripts of the extensions, the migrations of the system database and the READMEs. The first release, 0.1.0, was published on 2026-11-28; the install scripts of the default versions (kingres_shard 0.9, kingres_ledger 0.3, kingres_columnar 0.2, kingres_timepart 0.3, kingres_sketch 1.0) and the migrations 0001 to 0045 of the system database are the sources of the data model pages.
KingresDB keeps five kinds of data. They have different owners and different trust.
| Kind | Where it lives | Who writes it | Page |
|---|---|---|---|
| User data | ordinary tables, hash-partitioned into buckets across shard groups; reference tables copied whole to every node | the application | Data Model Sharding |
| Sharding catalog | schema kingres in every database of every node: nodes, colocation groups, bucket map, distributed schemas, user partitions, moves, splits, table operations |
kingres_shard (the map group primary is the authority, the other nodes hold copies) |
Data Model Sharding |
| Ledger data | schema kingres, tables ledger_*, inside each shard group's database; a history table per updatable ledger table |
the extension kingres_ledger only (a guard refuses every other writer) |
Data Model Ledger |
| Cluster state | database kingres_system, schema kingres_cp, on the map group: tasks, servers, alerts, settings, standbys, failover and rebalance records, ledger keys, tiles, checkpoints, anchors, records of staged transfer files |
kingresd (the manager leader) |
Data Model System Database |
| Analytics storage | columnar files, the time-partitioning catalog, sketch values in ordinary columns |
kingres_columnar, kingres_timepart, kingres_sketch
|
Data Model Analytics |
Outside PostgreSQL, kingresd also keeps files: the certificate authority and server keys, the service credentials, the ledger signing key files, anchor credentials, the staged transfer files and their master key, the audit log and the record of what was published (published.json). See Data Security.
flowchart LR
app["Application"] --> pg["PostgreSQL node: user tables and kingres catalog"]
pg --> led["ledger tables"]
cp["kingresd"] --> sys["kingres_system database, schema kingres_cp"]
cp --> files["files: keys, audit log, published.json"]
cp --> pg
sys --> pub["Publication: tiles and checkpoints"]
pub --> anc["Anchor targets"]
pub --> ver["Verifier"]
Writes. A write to a distributed table can be sent to any node. The node routes each row by the hash of the distribution column (bucket = hash modulo the bucket count of the colocation group) to the shard group that owns the bucket. A statement that touches several groups commits with two-phase commit (PREPARE TRANSACTION on each participant, a durable commit decision on the origin, then COMMIT PREPARED). Reference tables are written on every node. See Architecture Runtime Views Sharding and Sharding.
Reads. A read is answered by the row-moving scan, which stays as the fallback for every query shape, or by a faster path (pushdown) that sends the statement or a partial aggregate to the groups. Each group is read at its own snapshot; there is no global snapshot (phase 8 is in design, not built). See Sharding Query Pushdown.
Replication. A shard group is a primary and optional standbys on streaming physical replication, created by kingresd with pg_basebackup. A synchronous standby makes the outcome of a distributed transaction atomic across a failover. Catalog changes are made on the map group primary and pushed to the other nodes (sync_catalog), carrying a term so that a node refuses a push of an older term. See High Availability.
Moves. A bucket move copies the bucket's partitions to the target group with logical replication (a publication, a slot and a subscription), catches up, switches in the catalog, and keeps the old copy as kingres.orphan_* until move_cleanup_delay has passed. A bucket can also be split in 2, 4, 8 or 16 parts. See Rebalancing and Data Lifecycle.
Distributed schemas. In the schema mode of a database a whole schema is one unit of placement: its tables live on one shard group (a colocation group of kind schema with one bucket) and are empty shells on the others. A schema is moved with the same replication path as a bucket. See Sharding.
Export and import. A table is exported as CSV and a database as one zip archive, both as a sealed staged file on the manager leader, kept for a limited time and downloaded by the role that made it. An import reads an uploaded file as the importing role; a database import builds a private database and gives it its final name at the end. See Data Lifecycle and Data Security.
Table rebuilds. The online variants of distributing, undistributing and altering a table build a shadow table, copy, catch up with a captured log, swap, verify and keep the old copy for table_cleanup_delay. See Sharding Table Lifecycle.
Ledger publication and anchoring. A capture trigger writes one entry per row version; a background worker builds blocks; kingresd reads each group's chain through read functions, extends a transparency log per chain and an aggregate log per database in kingres_cp, signs checkpoints, and serves tiles on a listener. Anchoring sends the latest aggregate checkpoint to targets (WORM store, RFC 3161 authority, OpenTimestamps). An auditor checks it all with the verifier. See Ledger, Ledger Signing and Publication, Ledger Anchoring and The Verifier.
flowchart LR
w["Row write"] --> e["ledger_entry and ledger_pending"]
e --> b["ledger_tx and ledger_blocks"]
b --> t["chain log in kingres_cp: tiles and checkpoints"]
t --> a["aggregate log"]
a --> p["publication listener"]
a --> x["anchor targets"]
p --> v["kingres-verify"]
x --> v
- Lifecycle of data (partitions, retention, compaction, cleanup delays, archives): Data Lifecycle.
- Backup, restore and point-in-time recovery, and what they do to the ledger: Backup Restore and PITR.
- Secrets and hashing: Data Security.
- Checks that data is whole: Data Quality and Integrity.
- Components and containers: Architecture Containers, Architecture Components.
- https://github.com/KingresDB/Kingres/blob/kingres-18/contrib/kingres_shard/kingres_shard--0.9.sql
- https://github.com/KingresDB/Kingres/blob/kingres-18/contrib/kingres_ledger/kingres_ledger--0.3.sql
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/control-plane/internal/sysdb/migrations/0001_init.sql
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/adr/0019-cluster-state-in-a-system-database.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/adr/0009-two-phase-commit-no-global-snapshot.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/adr/0022-the-complete-scan-stays.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/contrib/kingres_shard/README.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/contrib/kingres_ledger/README.md
- https://github.com/KingresDB/Kingres/blob/kingres-18/kingres/docs/design/ledger-phase7.md
KingresDB's own code is licensed under AGPL-3.0-only. PostgreSQL code keeps the PostgreSQL License. Copyright of the project's own code: RooyeKhat Media Co. KingresDB is derived from PostgreSQL and is not endorsed by the PostgreSQL project. Repository | Licence | COPYRIGHT
KingresDB
1. Product
- Product Overview and Features
- Status and Roadmap
- User Guide
- Administrator Guide
- REST API Reference
- Web Console
- Command Line Client
- Extensions
- Limitations and Known Issues
- Release Notes
Features in detail
- Sharding
- Sharding Query Pushdown
- Sharding Table Lifecycle
- High Availability
- Ledger
- Ledger Signing and Publication
- Ledger Anchoring
- The Verifier
- Analytics Extensions
Administration
- Cluster Setup
- Servers Databases and Roles
- Rebalancing
- Configuration
- Memory and Warm-up
- Control Plane and REST API
- Upgrades
2. Architecture (arc42)
- Architecture
- Architecture Introduction and Goals
- Architecture Constraints
- Architecture System Context
- Architecture Containers
- Architecture Components
- Architecture Runtime Views Sharding
- Architecture Runtime Views Availability and Ledger
- Architecture Deployment
- Architecture Crosscutting Concepts
- Security Model
- Architecture Decisions
- Architecture Quality Requirements
- Architecture Risks and Technical Debt
- Enterprise Architecture
3. Data architecture
- Data Architecture
- Data Model Sharding
- Data Model Ledger
- Data Model System Database
- Data Model Analytics
- Data Lifecycle
- Backup Restore and PITR
- Data Security
- Data Quality and Integrity
4. Development
- Building from Source
- Development and Testing
- Repository Layout
- Coding Standards
- Branching and Synchronisation
- Testing Strategy
- Review Process
- Release Process
- Contributing
5. Operations