How can I prevent my finished queries to stay in pool?
Below is the image of my database and a lot of my finished queries are staying and I want them to be removed but don't know how.
This is my code that I made to sent the data from my database using Express:
Here is my articles.js file that sends the data as json.
router.get('/articles', (req, res) => {
let sql = "SELECT * FROM ARTICLES";
myDB.query(sql, (error, results) => {
if (error) {
console.log(error);
} else {
res.send(results)
}
})
});
and this is my connection.js that creates the connection to MySQL and Express
const mysql = require('mysql');
const myDB = mysql.createPool({
connectionLimit: 10,
host: 'REMOTE_DATABASE_ADDRESS',
user: 'hmidev',
password: 'hmidev',
database: 'VD_NEW_WEBSITE'
});
myDB.getConnection((error, connection) => {
if (error) {
console.log(error);
} else {
console.log(`Successfully connected at VD_NEW_WEBSITE`);
}
});
module.exports = myDB;
Best Answer
Connections left in a connection pool will show up as "Sleep" in
PROCESSLIST
. The "Time" will continue to grow until grabbed by a new "connect".