Fork me on GitHub
#sql
<
2019-04-03
>
tomas.arruda06:04:21

@seancorfield Thank you very much! What you suggested worked just fine!

kenny19:04:34

In a production app, is it best to pass a db-spec map or a persistent connection to the jdbc api?

noisesmith19:04:00

a db-spec map pointing to a connection pool object

seancorfield20:04:19

{:datasource pooled-datasource-object} is what we use at work @kenny where pooled-datasource-object is a c3p0 connection pool object

seancorfield20:04:56

Then the clojure.java.jdbc functions call .getConnection on the PDS each time they need a connection, which is low overhead.

seancorfield20:04:23

(that shows c3p0 specifically but any connection pooling library will suffice there)

kenny20:04:42

Oh, didn't see that doc. Thanks! Is passing the db-spec map without pooling to jdbc significantly more expensive than pooling?

seancorfield20:04:42

Creating a new database connection is significantly more expensive than getting one from a connection pool, yes.

kenny20:04:24

Why isn't pooling the default?

seancorfield20:04:16

Because there are multiple pooling libraries and because Contrib libs generally try to avoid external dependencies

seancorfield20:04:47

We happen to use c3p0 at work but a lot of people use Hikari-CP I think. There's another popular one too.

kenny20:04:10

Makes sense. Thanks again!