sql

All things SQL and JDBC...
Ben Sless 2020-08-11T07:06:41.443700Z

Should I expect to see a performance improvement with hugsql when switching from the default adapter to jdbc.next adapter? didn't see much difference when I tried it in a production environment.

lukasz 2020-08-11T14:52:23.445Z

We didn't notice any directly, but some things are nicer, like extending PG types as compared to clojure.jdbc

1
seancorfield 2020-08-11T15:49:49.446900Z

@ben.sless since HugSQL isn't using plan, the only performance difference you'll see is in "large" result sets that will be constructed quite a bit faster than with c.j.j

seancorfield 2020-08-11T15:50:06.447300Z

(that can be quite a substantial difference)

seancorfield 2020-08-11T15:51:01.448400Z

Also, if you construct a datasource once from a db-spec, and then use that datasource everywhere, that should also be a bit faster (using a connection pooled datasource would be faster, of course, and that is also true of c.j.j).

Ben Sless 2020-08-18T11:50:52.005800Z

Just wanted to update that I deployed next.jdbc today and I see speedups of up to 20% in some places. Thank you πŸ™‚

seancorfield 2020-08-18T16:36:03.007200Z

Nice! Thanks for following up on that!

πŸ™ 1
Ben Sless 2020-08-18T18:09:48.008600Z

Thank you for all the work you put into it and all the help you provide to the community

Ben Sless 2020-08-11T15:52:39.448600Z

I see. Thanks πŸ™‚

synthomat 2020-08-11T18:25:08.449300Z

using a datasource does jdbc-next re-connect to the database with each query?

synthomat 2020-08-11T18:25:15.449600Z

I’m not using connection pooling

synthomat 2020-08-11T18:26:38.451100Z

just wondering why my application reacts so slowly when deployed on a shared hoster. the response time locally is good

seancorfield 2020-08-11T19:03:22.453200Z

@synthomat Yes, if you use a db-spec (hash map) or connection URL string, then next.jdbc (and c.j.j) will make a datasource from that and then call .getConnection on it; if you use a datasource, both libraries will call .getConnection on it. You can either use get-connection and with-open (as shown in the docs) to reuse a connection across multiple operations, or you can use a connection pooled datasource (the recommended approach).

seancorfield 2020-08-11T19:04:04.454100Z

next.jdbc has built-in support for both HikariCP and c3p0 (and any others that follow the same API pattern as those two -- but those two are the supported and tested ones).

seancorfield 2020-08-11T19:04:51.454900Z

On shared hosting, it's entirely possible that standing up a new DB connection is very expensive (it's expensive, in relative terms, even locally but not so much that you really notice).

seancorfield 2020-08-11T19:06:17.455400Z

For any type of production app, I would always use connection pooling https://cljdoc.org/d/seancorfield/next.jdbc/1.1.582/doc/getting-started#connection-pooling

synthomat 2020-08-11T19:28:17.457600Z

It’s actually my own instance running in my isolated process group. But anyway I should use a pooling datasource. Thanks for the answer!