Skip to content

Instantly share code, notes, and snippets.

@arkadiybutermanov
Created March 20, 2020 15:49
Show Gist options
  • Save arkadiybutermanov/2fdd0bdedad59528bf9c50ff7d4089b5 to your computer and use it in GitHub Desktop.
Save arkadiybutermanov/2fdd0bdedad59528bf9c50ff7d4089b5 to your computer and use it in GitHub Desktop.
Generating Benchmarking data with Postgres
-- creating example tables
CREATE TABLE audits(id SERIAL PRIMARY KEY, title VARCHAR(255) NOT NULL, created_at timestamp NOT NULL);
CREATE TABLE objectives(id SERIAL PRIMARY KEY, title VARCHAR(255) NOT NULL, created_at timestamp NOT NULL, audit_id integer REFERENCES audits(id) NOT NULL);
-- generating 1000 audits
INSERT INTO audits(title, created_at) SELECT format('Audit #%s', id), current_timestamp FROM generate_series(1, 1000) AS id;
-- generating 100 objectives for each existing audits
INSERT INTO objectives(title, created_at, audit_id) SELECT format('Objective #%s', objective_id), current_timestamp, audits.id FROM audits, generate_series(1, 100) as objective_id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment