On Fri, Jan 7, 2011 at 12:22 AM, Shantanu Kumar <kumar.shant...@gmail.com> wrote: > On Jan 7, 6:49 am, Ken Wesson <kwess...@gmail.com> wrote: >> I'd hope it has some kind of caching or memoization behind the scenes, >> but if not, that'd be a great thing to add for version 1.1. I think a >> typical database client app uses a finite variety of prepared >> statements (each with potentially changing parameter values), so >> straight memoization ought to do fine and clojure already natively >> supports that, so ... > > The tricky part is - a PreparedStatement object is created and is > valid only in the context of a Connection object (because statement > compilation is database specific, and often needs an extra roundtrip > to the database).
That's icky. It's not common for one app to use two separate databases in a single running instance, so the PreparedStatement should really be valid across connections as long as they're to the same server. Failing that, though, keeping the Connection object alive makes sense anyway as another optimization. It's common for web browsers to keep one or a few HTTP connections to a server alive for a while after retrieving a page, in case the user browses repeatedly to links that stay inside the one site. If a page has lots of images loaded from a single server it also comes in handy to reuse a single connection for the whole batch. It makes sense to do something similar with database connections. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en