1MYSQLSLAP(1) MySQL Database System MYSQLSLAP(1)
2
3
4
6 mysqlslap - load emulation client
7
9 mysqlslap [options]
10
12 mysqlslap is a diagnostic program designed to emulate client load for a
13 MySQL server and to report the timing of each stage. It works as if
14 multiple clients are accessing the server. mysqlslap is available as
15 of MySQL 5.1.4.
16
17 Invoke mysqlslap like this:
18
19 shell> mysqlslap [options]
20
21 Some options such as --create or --query enable you to specify a string
22 containing an SQL statement or a file containing statements. If you
23 specify a file, by default it must contain one statement per line.
24 (That is, the implicit statement delimiter is the newline character.)
25 Use the --delimiter option to specify a different delimiter, which
26 enables you to specify statements that span multiple lines or place
27 multiple statements on a single line. You cannot include comments in a
28 file; mysqlslap does not understand them.
29
30 mysqlslap runs in three stages:
31
32 1. Create schema, table, and optionally any stored programs or data to
33 use for the test. This stage uses a single client connection.
34
35 2. Run the load test. This stage can use many client connections.
36
37 3. Clean up (disconnect, drop table if specified). This stage uses a
38 single client connection.
39
40 Examples:
41
42 Supply your own create and query SQL statements, with 50 clients
43 querying and 200 selects for each (enter the command on a single line):
44
45 mysqlslap --delimiter=";"
46 --create="CREATE TABLE a (b int);INSERT INTO a VALUES (23)"
47 --query="SELECT * FROM a" --concurrency=50 --iterations=200
48
49 Let mysqlslap build the query SQL statement with a table of two INT
50 columns and three VARCHAR columns. Use five clients querying 20 times
51 each. Do not create the table or insert the data (that is, use the
52 previous test's schema and data):
53
54 mysqlslap --concurrency=5 --iterations=20
55 --number-int-cols=2 --number-char-cols=3
56 --auto-generate-sql
57
58 Tell the program to load the create, insert, and query SQL statements
59 from the specified files, where the create.sql file has multiple table
60 creation statements delimited by ';' and multiple insert statements
61 delimited by ';'. The --query file will have multiple queries delimited
62 by ';'. Run all the load statements, then run all the queries in the
63 query file with five clients (five times each):
64
65 mysqlslap --concurrency=5
66 --iterations=5 --query=query.sql --create=create.sql
67 --delimiter=";"
68
69 mysqlslap supports the following options, which can be specified on the
70 command line or in the [mysqlslap] and [client] groups of an option
71 file. mysqlslap also supports the options for processing option files
72 described at Section 4.2.3.4, “Command-Line Options that Affect Option-
73 File Handling”.
74
75 · --help, -?
76
77 Display a help message and exit.
78
79 · --auto-generate-sql, -a
80
81 Generate SQL statements automatically when they are not supplied in
82 files or using command options.
83
84 · --auto-generate-sql-add-autoincrement
85
86 Add an AUTO_INCREMENT column to automatically generated tables.
87 This option was added in MySQL 5.1.18.
88
89 · --auto-generate-sql-execute-number=N
90
91 Specify how many queries to generate automatically. This option was
92 added in MySQL 5.1.18.
93
94 · --auto-generate-sql-guid-primary
95
96 Add a GUID-based primary key to automatically generated tables.
97 This option was added in MySQL 5.1.18.
98
99 · --auto-generate-sql-load-type=type
100
101 Specify the test load type. The permissible values are read (scan
102 tables), write (insert into tables), key (read primary keys),
103 update (update primary keys), or mixed (half inserts, half scanning
104 selects). The default is mixed. This option was added in MySQL
105 5.1.16.
106
107 · --auto-generate-sql-secondary-indexes=N
108
109 Specify how many secondary indexes to add to automatically
110 generated tables. By default, none are added. This option was added
111 in MySQL 5.1.18.
112
113 · --auto-generate-sql-unique-query-number=N
114
115 How many different queries to generate for automatic tests. For
116 example, if you run a key test that performs 1000 selects, you can
117 use this option with a value of 1000 to run 1000 unique queries, or
118 with a value of 50 to perform 50 different selects. The default is
119 10. This option was added in MySQL 5.1.18.
120
121 · --auto-generate-sql-unique-write-number=N
122
123 How many different queries to generate for
124 --auto-generate-sql-write-number. The default is 10. This option
125 was added in MySQL 5.1.18.
126
127 · --auto-generate-sql-write-number=N
128
129 How many row inserts to perform on each thread. The default is 100.
130 This option was added in MySQL 5.1.16.
131
132 · --commit=N
133
134 How many statements to execute before committing. The default is 0
135 (no commits are done). This option was added in MySQL 5.1.21.
136
137 · --compress, -C
138
139 Compress all information sent between the client and the server if
140 both support compression.
141
142 · --concurrency=N, -c N
143
144 The number of clients to simulate when issuing the SELECT
145 statement.
146
147 · --create=value
148
149 The file or string containing the statement to use for creating the
150 table.
151
152 · --create-schema=value
153
154 The schema in which to run the tests. This option was added in
155 MySQL 5.1.5.
156
157 Note
158 If the --auto-generate-sql option is also given, mysqlslap
159 drops the schema at the end of the test run. To avoid this, use
160 the --no-drop option as well.
161
162 · --csv[=file_name]
163
164 Generate output in comma-separated values format. The output goes
165 to the named file, or to the standard output if no file is given.
166 This option was added in MySQL 5.1.5.
167
168 · --debug[=debug_options], -# [debug_options]
169
170 Write a debugging log. A typical debug_options string is
171 'd:t:o,file_name'. The default is 'd:t:o,/tmp/mysqlslap.trace'.
172
173 · --debug-check
174
175 Print some debugging information when the program exits. This
176 option was added in MySQL 5.1.21.
177
178 · --debug-info, -T
179
180 Print debugging information and memory and CPU usage statistics
181 when the program exits. This option was added in MySQL 5.1.21.
182
183 · --delimiter=str, -F str
184
185 The delimiter to use in SQL statements supplied in files or using
186 command options.
187
188 · --detach=N
189
190 Detach (close and reopen) each connection after each N statements.
191 The default is 0 (connections are not detached). This option was
192 added in MySQL 5.1.21.
193
194 · --engine=engine_name, -e engine_name
195
196 The storage engine to use for creating tables.
197
198 · --host=host_name, -h host_name
199
200 Connect to the MySQL server on the given host.
201
202 · --iterations=N, -i N
203
204 The number of times to run the tests.
205
206 · --lock-directory=path
207
208 The directory to use for storing locks. This option was added in
209 MySQL 5.1.5 and removed in 5.1.18.
210
211 · --no-drop
212
213 Prevent mysqlslap from dropping any schema it creates during the
214 test run. This option was added in MySQL 5.1.57.
215
216 · --number-char-cols=N, -x N
217
218 The number of VARCHAR columns to use if --auto-generate-sql is
219 specified.
220
221 · --number-int-cols=N, -y N
222
223 The number of INT columns to use if --auto-generate-sql is
224 specified.
225
226 · --number-of-queries=N
227
228 Limit each client to approximately this many queries. Query
229 counting takes into account the statement delimiter. For example,
230 if you invoke mysqlslap as follows, the ; delimiter is recognized
231 so that each instance of the query string counts as two queries. As
232 a result, 5 rows (not 10) are inserted.
233
234 shell> mysqlslap --delimiter=";" --number-of-queries=10
235 --query="use test;insert into t values(null)"
236
237 This option was added in MySQL 5.1.5.
238
239 · --only-print
240
241 Do not connect to databases. mysqlslap only prints what it would
242 have done. This option was added in MySQL 5.1.5.
243
244 · --password[=password], -p[password]
245
246 The password to use when connecting to the server. If you use the
247 short option form (-p), you cannot have a space between the option
248 and the password. If you omit the password value following the
249 --password or -p option on the command line, mysqlslap prompts for
250 one.
251
252 Specifying a password on the command line should be considered
253 insecure. See Section 6.1.2.1, “End-User Guidelines for Password
254 Security”. You can use an option file to avoid giving the password
255 on the command line.
256
257 · --pipe, -W
258
259 On Windows, connect to the server using a named pipe. This option
260 applies only if the server supports named-pipe connections.
261
262 · --port=port_num, -P port_num
263
264 The TCP/IP port number to use for the connection.
265
266 · --post-query=value
267
268 The file or string containing the statement to execute after the
269 tests have completed. This execution is not counted for timing
270 purposes. This option was added in MySQL 5.1.18.
271
272 · --shared-memory-base-name=name
273
274 On Windows, the shared-memory name to use, for connections made
275 using shared memory to a local server. This option applies only if
276 the server supports shared-memory connections.
277
278 · --post-system=str
279
280 The string to execute using system() after the tests have
281 completed. This execution is not counted for timing purposes. This
282 option was added in MySQL 5.1.21.
283
284 · --pre-query=value
285
286 The file or string containing the statement to execute before
287 running the tests. This execution is not counted for timing
288 purposes. This option was added in MySQL 5.1.18.
289
290 · --pre-system=str
291
292 The string to execute using system() before running the tests. This
293 execution is not counted for timing purposes. This option was added
294 in MySQL 5.1.21.
295
296 · --preserve-schema
297
298 Preserve the schema from the mysqlslap run. The --auto-generate-sql
299 and --create options disable this option. This option was added in
300 MySQL 5.1.5 and removed in MySQL 5.1.23.
301
302 · --protocol={TCP|SOCKET|PIPE|MEMORY}
303
304 The connection protocol to use for connecting to the server. It is
305 useful when the other connection parameters normally would cause a
306 protocol to be used other than the one you want. For details on the
307 permissible values, see Section 4.2.2, “Connecting to the MySQL
308 Server”.
309
310 · --query=value, -q value
311
312 The file or string containing the SELECT statement to use for
313 retrieving data.
314
315 · --silent, -s
316
317 Silent mode. No output.
318
319 · --slave
320
321 Follow master locks for other mysqlslap clients. Use this option if
322 you are trying to synchronize around one master server with
323 --lock-directory plus NFS. This option was added in MySQL 5.1.5 and
324 removed in 5.1.18.
325
326 · --socket=path, -S path
327
328 For connections to localhost, the Unix socket file to use, or, on
329 Windows, the name of the named pipe to use.
330
331 · --ssl*
332
333 Options that begin with --ssl specify whether to connect to the
334 server using SSL and indicate where to find SSL keys and
335 certificates. See Section 6.3.6.4, “SSL Command Options”.
336
337 · --use-threads
338
339 On Unix, the default is to use fork() calls and this option causes
340 pthread calls to be used instead. (On Windows, the default is to
341 use pthread calls and the option has no effect.) This option was
342 added in MySQL 5.1.6 and removed in 5.1.18.
343
344 · --user=user_name, -u user_name
345
346 The MySQL user name to use when connecting to the server.
347
348 · --verbose, -v
349
350 Verbose mode. Print more information about what the program does.
351 This option can be used multiple times to increase the amount of
352 information.
353
354 · --version, -V
355
356 Display version information and exit.
357
359 Copyright © 1997, 2013, Oracle and/or its affiliates. All rights
360 reserved.
361
362 This documentation is free software; you can redistribute it and/or
363 modify it only under the terms of the GNU General Public License as
364 published by the Free Software Foundation; version 2 of the License.
365
366 This documentation is distributed in the hope that it will be useful,
367 but WITHOUT ANY WARRANTY; without even the implied warranty of
368 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
369 General Public License for more details.
370
371 You should have received a copy of the GNU General Public License along
372 with the program; if not, write to the Free Software Foundation, Inc.,
373 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
374 http://www.gnu.org/licenses/.
375
376
378 For more information, please refer to the MySQL Reference Manual, which
379 may already be installed locally and which is also available online at
380 http://dev.mysql.com/doc/.
381
383 Oracle Corporation (http://dev.mysql.com/).
384
385
386
387MySQL 5.1 11/04/2013 MYSQLSLAP(1)