I want to create a large sample of data (almost 1 million records) to study the multiphase merge of tuplesort.c in postgresql, and I hope the schema looks like this:
CREATE TABLE Departments (code VARCHAR(4), UNIQUE (code));
CREATE TABLE Towns (
id SERIAL UNIQUE NOT NULL,
code VARCHAR(10) NOT NULL,
article TEXT,
name TEXT NOT NULL,
department VARCHAR(4) NOT NULL REFERENCES Departments (code),
UNIQUE (code, department)
);
how to use generate_series and random for this? Thank you so much!
source
share