February 2020
Intermediate to advanced
734 pages
38h 13m
English
All SQL statements in this recipe should be executed by the postgres database user. Follow these steps to build a table to map logical shards to their physical locations:
CREATE TABLE shard.shard_map ( map_id SERIAL PRIMARY KEY, shard_id INT NOT NULL, source_schema VARCHAR NOT NULL, shard_schema VARCHAR NOT NULL, server_name VARCHAR NOT NULL, UNIQUE (shard_id, source_schema) );
CREATE SCHEMA myapp1; INSERT INTO shard.shard_map (shard_id, source_schema, shard_schema, server_name) VALUES (1, 'myapp', 'myapp1', 'pg-primary');
Read now
Unlock full access