Introduction to Connection Pools
Although it's convenient for clojure.java.jdbc
to create our database connections for us (it does this on each API call when we pass it a db-spec
definition), there is a resulting performance overhead we should be aware of. This can become burdensome as establishing a connection (particularly to a remote machine) can often take many times longer than our query will actually take to execute! This is, therefore, an expensive operation that we'd like to avoid. Connection pooling is one such way of avoiding this overhead.
When we talk of a connection pool, we're essentially talking about establishing one or more connections ahead of time and making them available to our application anytime a database connection is required. In this way, we deal with the connection overhead once on application startup and benefit from connection reuse from that point onward.
clojure.java.jdbc
does not itself offer a connection pooling implementation...