Updated on 2025-03-18 GMT+08:00

Concepts

Databases

Databases manage various data objects and are isolated from each other. While creating a database, you can specify a tablespace. If you do not specify it, the object will be saved to the PG_DEFAULT tablespace by default. Objects managed by a database can be distributed to multiple tablespaces.

Tablespaces

In GaussDB, a tablespace is a directory storing physical files of the databases. An instance may contain multiple tablespaces. Files are physically isolated using tablespaces and managed by a file system.

Schemas

GaussDB schemas logically separate databases. All database objects are created under certain schemas. In GaussDB, schemas and users are loosely bound. When you create a user, a schema with the same name as the user will be created automatically. You can also create a schema or specify another schema.

Users and Roles

GaussDB uses users and roles to control the access to databases. A role can be a database user or a group of database users, depending on role settings. Each user can have only one role. In GaussDB, the difference between roles and users is that a role does not have the LOGIN permission by default. In GaussDB, you can put a user's role under a parent role for flexible management.

Transactions

In GaussDB, transactions are managed by multi-version concurrency control (MVCC) and two-phase locking (2PL). It enables smooth data reads and writes. In GaussDB, an Astore stores historical version data together with the current tuple version. The GaussDB Astore uses a VACUUM thread instead of rollback segments to periodically delete historical version data. Generally, you do not need to pay special attention to the VACUUM thread unless you need to optimize the performance. The GaussDB Ustore stores historical version data to the undo rollback segments. The thread for purging undo deletes historical version data in a unified manner. In addition, GaussDB automatically commits transactions for single-statement queries (without using statements such as BEGIN to explicitly start a transaction block).

TOAST

The Oversized-Attribute Storage Technique (TOAST) is a special storage technique used to overcome the limitation that a single field in the database is too large to be directly stored in a standard data page. GaussDB uses a fixed page size, typically 8 KB. When the size of a row of data exceeds the page size, the database employs TOAST to ensure that these oversized fields can be effectively stored and managed. Out-of-line storage is a part of TOAST. This technology compresses or slices large field values into multiple physical rows and stores them in another table (known as the TOAST table). The main table retains only references (usually pointers) to these large field values. If a table has an associated TOAST table, the reltoastrelid column in the PG_CLASS system catalog records the OID of the TOAST table. If the table has no such an associated TOAST table, the value of reltoastrelid is 0.