title: Knex.js / SQL : Knex / SQL Connection Pools
body: <p>I have a question regarding SQL connection pools. My team is using the knex.js library in one of our node applications to make database query's.
  The application from time to time needs to switch databases. So my team created an initialization function that returns a knex object configured to the correct database. Then that object is used to do said query. To me this seems redundant and can cause bad performance, because we initiate a knex object every time need to do a query instead of reusing a single knex object. Which i could ignore if knex already does this when you which databases (and if anyone could shed light on this question as well that would be FANTASTIC !) . Moreover, (and this leads me to my question titled above) the connection pool properties are redefined. So does that mean we are creating new pools every time, or does the SQL ( SQL Sever in this case) reuse the connection pool you already defined ? The question might not be Knex specific, like if i used a library like knex for C#, and call that library a similar way, would SQL Server know not to make more connection pools? </p>
  
  <p>Example code:</p>
  
  <pre><code>/** db.js
   * @param {any} database 
   * @returns db: Knex
   */
  module.exports = ( database ) =&gt; {
    var knex = require('knex')({
      client: 'mssql',
      connection: {
          database: database,
          server:  '127.0.0.1',
          user: 'your_database_user',
          password: 'your_database_password'
      },
      pool: {
          min: 0,
          max: 10,
          idleTimeoutMillis: 5000,
          softIdleTimeoutMillis: 2000,
          evictionRunIntervalMillis: 500
      }
    });
    return knex; 
  }; 
  
  
  Index.js
  
  var db = require('./db.js'); 
  /**
   * @returns users:Array
   */
  const getUsers = async() =&gt; {
      const users = await db('master')
              .select()
              .from('users_table')
              .orderBy('user_id'); 
      return users; 
  }
  </code></pre>