Hi!
Our company is testing options to scale our database and we think Citus can be the solution we need. :-)
Although we're finding problems on how to adapt our current Postgres database schema to Citus requirements.
We want to create distributed tables based on a company_id, but there are other unique/primary keys on those tables
and that's not allowed.
An example of what we want to achieve using one of the tutorials from Citus documentation.
If we start with this:
CREATE TABLE wikipedia_editors (
editor TEXT UNIQUE, -- The name of the editor
bot BOOLEAN, -- Whether they are a bot (self-reported)
edit_count INT, -- How many edits they've made
added_chars INT, -- How many characters they've added
removed_chars INT, -- How many characters they've removed
first_seen TIMESTAMPTZ, -- The time we first saw them edit
last_seen TIMESTAMPTZ -- The time we last saw them edit
);
But we also have an ID, a UNIQUE key (like slug for example) and our company_id, what would be the best solution to be able to distribute this table?
Example:
CREATE TABLE wikipedia_editors (
id PRIMARY KEY,
slug TEXT UNIQUE,
company_id INT UNIQUE,
editor TEXT UNIQUE, -- The name of the editor
bot BOOLEAN, -- Whether they are a bot (self-reported)
edit_count INT, -- How many edits they've made
added_chars INT, -- How many characters they've added
removed_chars INT, -- How many characters they've removed
first_seen TIMESTAMPTZ, -- The time we first saw them edit
last_seen TIMESTAMPTZ -- The time we last saw them edit
);
We want to do:
SELECT master_create_distributed_table('wikipedia_changes', 'company_id', 'hash');
Thank you!