mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-16 12:58:00 +00:00
25dc7bfe72
# Which Problems Are Solved Cache implementation using a PGX connection pool. # How the Problems Are Solved Defines a new schema `cache` in the zitadel database. A table for string keys and a table for objects is defined. For postgreSQL, tables are unlogged and partitioned by cache name for performance. Cockroach does not have unlogged tables and partitioning is an enterprise feature that uses alternative syntax combined with sharding. Regular tables are used here. # Additional Changes - `postgres.Config` can return a pxg pool. See following discussion # Additional Context - Part of https://github.com/zitadel/zitadel/issues/8648 - Closes https://github.com/zitadel/zitadel/issues/8647 --------- Co-authored-by: Silvan <silvan.reusser@gmail.com>
28 lines
885 B
SQL
28 lines
885 B
SQL
create schema if not exists cache;
|
|
|
|
create table if not exists cache.objects (
|
|
cache_name varchar not null,
|
|
id uuid not null default gen_random_uuid(),
|
|
created_at timestamptz not null default now(),
|
|
last_used_at timestamptz not null default now(),
|
|
payload jsonb not null,
|
|
|
|
primary key(cache_name, id)
|
|
);
|
|
|
|
create table if not exists cache.string_keys(
|
|
cache_name varchar not null check (cache_name <> ''),
|
|
index_id integer not null check (index_id > 0),
|
|
index_key varchar not null check (index_key <> ''),
|
|
object_id uuid not null,
|
|
|
|
primary key (cache_name, index_id, index_key),
|
|
constraint fk_object
|
|
foreign key(cache_name, object_id)
|
|
references cache.objects(cache_name, id)
|
|
on delete cascade
|
|
);
|
|
|
|
create index if not exists string_keys_object_id_idx
|
|
on cache.string_keys (cache_name, object_id); -- for delete cascade
|