@@ -7,30 +7,78 @@ Nancy helps to conduct automated database experiments.
7
7
The Nancy Command Line Interface is a unified way to manage automated
8
8
database experiments either in clouds or on-premise.
9
9
10
- Experiments are needed every time you:
10
+ What is a Database Experiment?
11
+ ===
12
+ Database experiment is a set of actions performed to test
13
+ * (a) specified SQL queries ("workload")
14
+ * (b) on specified machine / OS / Postgres version ("environment")
15
+ * (c) against specified database ("object")
16
+ * (d) with an optional change – some DDL or config change ("target" or "delta").
17
+
18
+ Two main goals for any database experiment:
19
+ * (1) validation – check that the specified workload is valid,
20
+ * (2) benchmark – perform deep SQL query analysis.
21
+
22
+ Database experiments are needed when you:
11
23
- add or remove indexes;
12
- - want to verify query optimization ideas;
13
- - need to tune database parameters;
14
- - want to perform performance/stress test for your DB;
15
- - are preparing to upgrade your DBMS to the new major version;
24
+ - for a new DB schema change, want to validate it and estimate migration time;
25
+ - want to verify some query optimization ideas;
26
+ - tune database configuration parameters;
27
+ - do capacity planning and want to stress-test your DB in some environment;
28
+ - plan to upgrade your DBMS to a new major version;
16
29
- want to train ML model related to DB optimization.
17
30
18
- Currently Nancy works only with PostgreSQL versions 9.6 and 10.
31
+ Currently Supported Features
32
+ ===
33
+ * Experiments are conducted in a Docker container with extended Postgres setup
34
+ * Supported Postgres versions: 9.6, 10
35
+ * Supported locations for experimental runs:
36
+ * Any machine with Docker installed
37
+ * AWS EC2:
38
+ * Run on AWS EC2 Spot Instances (using Docker Machine)
39
+ * Allow to specify EC2 instance type
40
+ * Auto-detect and use current lowest EC2 Spot Instance prices
41
+ * Support local or remote (S3) files – config, dump, etc
42
+ * What to test (a.k.a. "target" or "delta"):
43
+ * Test Postgres parameters change
44
+ * Test DDL change (specified as "do" and "undo" SQL to return state)
45
+ * Supported types of workload:
46
+ * Use custom SQL as workload
47
+ * Use "real workload" prepared using Postgres logs
48
+ * For "real workload", allow replaying it with increased speed
49
+ * Allow to keep container alive for specified time after all steps are done
50
+ * Collected artifacts:
51
+ * Workload SQL logs
52
+ * Deep SQL query analysis report
19
53
20
54
Requirements
21
55
===
22
- To use Nancy CLI you need Linux or MacOS with installed Docker. If you plan
23
- to run experiments in AWS EC2 instances, you also need Docker Machine
24
- (https://docs.docker.com/machine/ ).
56
+ 1 ) To use Nancy CLI you need Linux or MacOS with installed Docker.
57
+
58
+ 2 ) To run on AWS EC2 instances, you also need:
59
+ * AWS CLI https://aws.amazon.com/en/cli/
60
+ * Docker Machine https://docs.docker.com/machine/
61
+ * jq https://stedolan.github.io/jq/
62
+
25
63
26
64
Installation
27
65
===
66
+
67
+ In the minimal configuration, only two steps are needed:
68
+
69
+ 1 ) Install Docker (for Ubuntu/Debian: ` sudo apt-get install docker ` )
70
+ 2 ) Clone this repo and adjust ` $PATH ` :
28
71
``` bash
29
72
git clone https://github.com/startupturbo/nancy
30
73
echo " export PATH=\$ PATH:" $( pwd) " /nancy" >> ~ /.bashrc
31
74
source ~ /.bashrc
32
75
```
33
76
77
+ Additionally, to allow use of AWS EC2 instances:
78
+ 3 ) Follow instructions https://docs.aws.amazon.com/cli/latest/userguide/installing.html
79
+ 4 ) Follow instructions https://docs.docker.com/machine/install-machine/
80
+ 5 ) install jq (for Ubuntu/Debian: ` sudo apt-get install jq ` )
81
+
34
82
Getting started
35
83
===
36
84
Start with these commands:
@@ -39,3 +87,25 @@ nancy help
39
87
nancy run help
40
88
```
41
89
90
+ "Hello World!"
91
+ ===
92
+ ``` bash
93
+ echo " create table hello_world as select i::int4 from generate_series(1, 1000000) _(i);" > ./sample.dump
94
+ bzip2 ./sample.dump
95
+
96
+ # "Clean run": w/o index
97
+ # (seqscan is expected, total time ~150ms, depending on resources)
98
+ nancy run \
99
+ --run-on localhost \
100
+ --workload-custom-sql " select count(1) from hello_world where i between 100000 and 100010;" \
101
+ --db-dump-path file://$( pwd) /sample.dump.bz2 --tmp-path /tmp
102
+
103
+ # Now check how a regular btree index affects performance
104
+ # (expected total time: ~0.05ms)
105
+ nancy run \
106
+ --run-on localhost \
107
+ --workload-custom-sql " select count(1) from hello_world where i between 100000 and 100010;" \
108
+ --db-dump-path file://$( pwd) /sample.dump.bz2 --tmp-path /tmp \
109
+ --target-ddl-do " create index i_hello_world_i on hello_world(i);" \
110
+ --target-ddl-undo " drop index i_hello_world_i;"
111
+ ```
0 commit comments