Getting ready

We will actually be starting from scratch in this recipe and will no longer use the pgbench tables. Instead, we want to start with new shell tables designed specifically for sharding. Execute these SQL statements as the postgres user on an empty database to get ready:

CREATE SCHEMA myapp;
CREATE TABLE myapp.msg_log (
  id       SERIAL  PRIMARY KEY,
  message  TEXT    NOT NULL
);

We will be using this schema and table for the rest of this chapter.

Get PostgreSQL High Availability Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.