Registry / database / mysql-pool-booster

mysql-pool-booster

JSON →
library1.0.3jsnpmunverified

A lightweight wrapper around the mysql npm package that enhances connection pool performance and adds configuration options inspired by Java DBCP (e.g., queueTimeout, testOnBorrow, minIdle, maxReuseCount). Version 1.0.3 is the latest stable release. It provides up to 80% throughput improvement for high-concurrency workloads by optimizing pool acquisition. Primarily maintained for legacy Node.js 0.6+ projects. The package monkey-patches the existing mysql module and extends both pool and PoolCluster functionality. Not compatible with the newer mysql2 driver or modern ESM imports.

npm install mysql-pool-booster
INSTALL
IMPORT
SIG · MYSQL-POOL-BOOSTER
M
mysql-pool-booster
databasejavascriptv1.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import mysql from 'mysql'; import MysqlPoolBooster from 'mysql-pool-booster'; mysql = MysqlPoolBooster(mysql);
const mysql = require('mysql-pool-booster')
The package does NOT export an enhanced mysql object directly; you must pass your existing mysql module into the booster function.
MysqlPoolBooster
const MysqlPoolBooster = require('mysql-pool-booster')
import { MysqlPoolBooster } from 'mysql-pool-booster'
The package only exports a single default function – do not use named import.
pool.query
const pool = mysql.createPool({...}); pool.query(sql, callback)
pool.getConnection((err, conn) => conn.query(sql, callback))
The booster adds a direct `pool.query()` method for convenience, similar to the mysql2 API. This is not available in the original mysql module's pool.

Create a boosted mysql connection pool with extended options and use the convenient pool.query shorthand.

const mysql = require('mysql'); const MysqlPoolBooster = require('mysql-pool-booster'); mysql = MysqlPoolBooster(mysql); const pool = mysql.createPool({ host: 'localhost', user: 'root', password: process.env.MYSQL_PASSWORD ?? '', database: 'test', // Booster options queueTimeout: 5000, // wait max 5s for a connection testOnBorrow: true, testOnBorrowInterval: 20000, minIdle: 2, maxIdle: 10, maxReuseCount: 1000, timeBetweenEvictionRunsMillis: 60000 }); // Use pool.query directly (booster adds this method) pool.query('SELECT 1 + 1 AS solution', (err, results) => { if (err) throw err; console.log('Result:', results[0].solution); });
Debug
Known issues
breakingThe package patch modifies the global mysql module object, which may affect other code relying on the original pool behavior.
fix
Always boost the mysql object immediately after require and before any other usage. Avoid boosting multiple times.
affects: *
deprecatedPackage is no longer actively developed; last release 2019. Works only with `mysql` module (not `mysql2`).
fix
Consider migrating to `mysql2` which has built-in promise support and better pool performance.
affects: all
gotchaWhen `testOnBorrow` is true (default), each pool connection borrow triggers a validation query (`SELECT 1`). This can cause unnecessary load.
fix
Set `testOnBorrow: false` if your connections are reliable, or increase `testOnBorrowInterval`.
affects: >=1.0.0
gotchaOlder Node versions (< 0.10) may not support the internal eviction timer properly.
fix
Upgrade Node.js to at least 0.10, or avoid using `timeBetweenEvictionRunsMillis`.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: MysqlPoolBooster is not a function
Default import used incorrectly (commonjs -> esm).
fix
Use `const MysqlPoolBooster = require('mysql-pool-booster')` instead of a named import.
Error: Module "mysql" is required
The booster function was called without passing the mysql module.
fix
Always call `MysqlPoolBooster(mysql)` with the mysql module as argument.
Error: Cannot find module 'mysql'
Package mysql not installed.
fix
Run `npm install mysql` before using mysql-pool-booster.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
mysqlrequiredPeer dependency – wraps and extends the mysql module's pool and PoolCluster
Agent activity
2 hits · last 30 days
node
2
Resources
mysql-pool-booster — npm install mysql-pool-booster · libregistry