Skip to content

Commit

Permalink
[test-data/] Formatting and updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dgroomes committed Jul 30, 2024
1 parent f2457db commit 42d8c5f
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions test-data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 42d8c5f

Please sign in to comment.