Q
Q
QQ2016-04-02 21:36:05
MySQL
QQ, 2016-04-02 21:36:05

What is the difference between a pool connection and a normal one in MySQL?

Hello.
From the documentation - https://github.com/felixge/node-mysql
I can't figure out what to choose, pool or regular, which is more productive?
For example, as I understand it, if I use pool like this (opened pool, connected once and left):

// books.js
mysql.getConnection(function(err, connection) {
    connection.query('SELECT * FROM books', function (err, books) {
        connection.release();
        // ...
    });
});
// book.js
mysql.getConnection(function(err, connection) {
    connection.query('SELECT * FROM books WHERE id = :id', {id: 12} function (err, books) {
        connection.release();
        // ...
    });
});

then you can change to a normal connection and do not lose anything?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
un1t, 2016-04-04
@botaniQQQ

Muscle is known for having a low connection overhead, so there might not be a big difference. Need to test.
In general, pool is more productive.
If you do not have huge performance requirements (thousands of requests per second), then you can choose any method and not worry.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question