From 42d8c5f8c8b759db4e1c3db2d788ec4b6dd7d63b Mon Sep 17 00:00:00 2001 From: David Groomes Date: Mon, 29 Jul 2024 21:04:53 -0500 Subject: [PATCH] [`test-data/`] Formatting and updates --- test-data/README.md | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/test-data/README.md b/test-data/README.md index 7c2f3db..e863b86 100644 --- a/test-data/README.md +++ b/test-data/README.md @@ -2,7 +2,8 @@ Generate test data to aid in performance exploration and analysis. -## Why? + +## Overview It's common to run into performance issues in production where accumulated data and high query volume to the database slows down the execution times of queries. To have a chance of catching those issues at development-time, we need to simulate @@ -14,23 +15,36 @@ data is easy! The `test-data` project shows how to generate a lot of basic data --- + ## Instructions Follow these instructions to generate test data in a local Postgres database. -1. Alias the psql command: - * `alias psqlDo="psql --username postgres --host localhost"` -1. Apply the schema: - * `psqlDo -f numbers-schema.ddl` -1. Generate one million rows of test data: - * `psqlDo -f generate-numbers.sql -v rows=1000000` -1. Execute a sort and notice how slow it is! - * `psqlDo -c 'explain analyze select x from numbers order by x'` +1. Start the Postgres server + * Use whatever method you prefer: HomeBrew, Docker, etc. Depending on how you install it, the username and database + name will differ so take care to adjust the `psql` commands accordingly. +2. Apply the schema: + * ```shell + psql -f numbers-schema.ddl + ``` +3. Generate one million rows of test data: + * ```shell + psql -f generate-numbers.sql -v rows=1000000 + ``` +4. Execute a sort and notice how slow it is! + * ```shell + psql -c 'explain analyze select x from numbers order by x' + ``` * Note that the `explain analyze` will conveniently print the execution time and not print the result set. -1. Generate **ten** million rows: - * `psqlDo -f generate-numbers.sql -v rows=10000000` -1. Execute the same sort operation and notice how it is many times slower: - * `psqlDo -c 'explain analyze select x from numbers order by x'` +5. Generate **ten** million rows: + * ```shell + psql -f generate-numbers.sql -v rows=10000000 + ``` +6. Execute the same sort operation and notice how it is many times slower: + * ```shell + psql -c 'explain analyze select x from numbers order by x' + ``` + ## Reference