You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+37-4
Original file line number
Diff line number
Diff line change
@@ -50,12 +50,32 @@ The program can detect if a field accepts NULLs and if it does, it will generate
50
50
## Options
51
51
|Option|Description|
52
52
|------|-----------|
53
+
|--bulk-size|Number of rows per INSERT statement (Default: 1000)|
54
+
|--debug|Show some debug information|
55
+
|--fk-samples-factor|Percentage used to get random samples for foreign keys fields. Default 0.3|
53
56
|--host|Host name/ip|
57
+
|--max-fk-samples|Maximum number of samples for fields having foreign keys constarints. Default: 100|
58
+
|--max-retries|Maximum number of rows to retry in case of errors. See duplicated keys. Deafult: 100|
59
+
|--password|Password|
54
60
|--port|Port number|
61
+
|--show-progressbar|Show the progress bar. Default: true|
55
62
|--user|Username|
56
-
|--password|Password|
57
-
|--bulk-size|Number of rows per INSERT statement (Default: 1000)|
58
-
|--debug|Show some debug information|
63
+
64
+
## Foreign keys support
65
+
If a field has Foreign Keys constraints, `random-data-load` will get up to `--max-fk-samples` random samples from the referenced tables in order to insert valid values for the field.
66
+
The number of samples to get follows this rules:
67
+
**1.** Get the aproximate number of rows in the referenced table using the `rows` field in:
68
+
```
69
+
EXPLAIN COUNT(*) FROM <referenced schema>.<referenced table>
70
+
```
71
+
**1.1** If the number of rows is less than `max-fk-samples`, all rows are retrieved from the referenced table using this query:
72
+
```
73
+
SELECT <referenced field> FROM <referenced schema>.<referenced table>
74
+
```
75
+
**1.2** If the number of rows is greater than `max-fk-samples`, samples are retrieved from the referenced table using this query:
76
+
```
77
+
SELECT <referenced field> FROM <referenced schema>.<referenced table> WHERE RAND() <= <fk-samples-factor> LIMIT <max-fk-samples>
78
+
```
59
79
60
80
### Example
61
81
```
@@ -135,6 +155,19 @@ tcol28: 6.12
135
155
136
156
## To do
137
157
-[ ] Add suport for all data types.
138
-
-[] Add supporrt for foreign keys.
158
+
-[X] Add supporrt for foreign keys.
139
159
-[ ] Support config files to override default values/ranges.
140
160
-[ ] Support custom functions via LUA plugins.
161
+
162
+
## Versions history
163
+
164
+
#### 0.1.2
165
+
- New table parser able to retrieve all the information for fields, indexes and foreign keys constraints.
0 commit comments