Fork me on GitHub
Shuky Badeer05:04:26

Hii guys! We're writing a clojure backend these days. The only missing piece of the puzzle is the database. What database is commonly used with clojure? I know that Datomic goes hand in hand with clojure but I find it strange that big companies use clojure without Datomic. So I wonder, in practicaliy, which database should we use?


Many people use traditional rdbms like MySQL, PostgreSQL, etc. There's next.jdbc library for that. Some (much fewer?) people use Datomic or XTDB (former Crux) if they have a need for the features they offer.

Shuky Badeer05:04:51

@U06BE1L6T thank you for the info. Datomic offers the immutable feature which is nice, but it proves to be slow in terms of querying large datasets. That's why we're skeptical about it


I never used these in production but Datomic and/or XTDB are something I would like to try seriously at some point. However, I saw people migrated from Datomic to PostgreSQL because of performance and costs. If you think you need Datomic's features I guess you have to judge it depending on your own context

👍 2

Maybe @U0KD0N5T5 can give you additional info - I know he talked about this stuff in #clojure-czech a long time ago.

👍 1

In their podcast, (#clojuredesign-podcast), @U5FV4MJHG and @U0510902N mention several times. But I suppose whether you need a “traditional” relational database or “NoSQL” or graph database depends on the particular problem and application. In addition to Datomic, you might want to check out (#asami) by our friend @U051N6TTC. What kind of data are you working on within your application, if I may ask? Perhaps that might help inform your choice.

👍 1

Another database I find particularly interesting because of its decentralization capabilities is If you have many distributed servers or clients, they can work on their own “local replica” of the database, even without an internet connection. When the internet connection comes back up, they will sync automatically. It’s like a non-ephemeral writable cache. This is made possible by the facilities of Erlang/OTP and the BEAM, upon which CouchDB is built. One use case that comes to mind is brick-and-mortar retail, where hundreds of distributed stores need to manage the same product master data even if the store has an unstable internet connection.

👍 1

There was a good discussion in #off-topic recently about why people don't like mongo much


Thanks for the link, @U06BE1L6T! I’m adding it to my to-read list!


PostgreSQL would be my favorite if you're not going for a datalog db.

💡 1
👍 1

@U04V15CAJ, are there any particular aspects of PostgreSQL which make it a better fit for Clojure projects than other SQL databases? Other than just being a “better” SQL database in general.


More reliable than MySQL, for one.


Unscientific answer, but it just feels more mature to me than any other OSS relational database.


Yeah, I get that! I would also opt for PostgreSQL (even if I wasn’t using Clojure). I was just curious if some aspects of PostgreSQL made it better for Clojure in particular.


Nothing specific to Clojure (until I get the dust off this thing:

👀 1
😮 1

In my previous job we used PostgreSQL together with ZomboDB which worked pretty well: it's a plugin that syncs it with ElasticSearch


Never heard of ZomboDB! I’ll have a peek.


We use SAP HANA (yuk!), Oracle Database (operations), and Snowflake (analysis) for structured and semistructured data in my current job. And Azure Blob Storage for unstructured stuff, like binaries, etc. Oh, and Kafka, which functions as a database in some scenarios if you squint your eyes and look at it from a weird angle. Before learning about Clojure, I played around with Neo4j at work for data science stuff… But now I think I’ll try Datomic (if I can convince my employer to buy it) or Asami instead.


@U01PE7630AC @U033V0AJFU4 I have used MongoDB quite a lot, but that is due to historical choices for myself and the projects I've worked on. For any new project that needs a relational database, I pick PostgreSQL these days. PostgreSQL also supports JSON for non-relational use. I'd love to use a datalog-style DB, but I haven't had occasion to use one yet.

👍 1
Joshua Suskalo23:04:42

I'll admit I'm really curious about the comparison of performance between datomic and datahike on postgres


I'm surprised to hear about slow performance on queries on Datomic? Do you have source for that? As far as I know, writes is the bottleneck, due to single writer design, but reads can be scaled horizontally, so maybe you mean individual queries are still too slow? But at least in theory it should scale out easily.


There's not really anything special about Clojure when it comes to DB choice. So choose your DB the same way you'd do for whatever the language you use. At my work we use AWS DynamoDB and S3 primarily for our operational use cases, with ElasticSearch for cross-record queries.


In the open-source, for relational, you can't go wrong with MySQL or MariaDB or PostgressSQL. PostgressSQL also has nice support for document store, and it has some nice relational features too that at least used to be missing from MySQL, like proper constraint enforcement of foreign keys. I also know a lot of people using Cassandra and CouchDB quite successfully as well, so those are good candidate to consider.


while i think it’s fair to say there is nothing special about clojure w/r/t DB choice, the ergonomics of use certainly vary