mysql.workers
mysql.workers
Function
Set the number of concurrent jobs for batch exec.
Syntax
mysql(dsn).query(sql).workers(count)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| count | Int | No | 1 | Number of jobs; valid range 1 to 4096. |
Return value
| Type | Description |
|---|---|
| Mysql | Returns the new MySQL query builder. |
Example
rows = [['A'], ['B']] db = mysql('mysql://user:pass@127.0.0.1/test') result = db.query('insert into user(name) values (?)').binds(rows).workers(4).sql() // Output: insert into user(name) values ('A'), ('B') /* binds: 2 rows, batch: 0, workers: 4 */ print result
Notes
- The number of underlying Tokio worker threads will be limited to the CPU parallelism and the upper limit of 64.
- all() and one() do not support workers.