simrayz
I’m using a Neo4j database to supplement my Postgresql database. Postgres is used to store the entities themselves (e.g. users), and should always be the one source of truth. However, I am struggling with figuring out how I make sure the Neo4j database consistent with my postgres database. I am using Ecto and Bolt.Sips as my database adapters.
How can I make sure that a user is only created/deleted/changed if the action is successful in both databases? Both Ecto and Bolt.Sips has transaction/rollback functionality, but is there a way to combine them?
This is what I have so far, but this would cause problems if the postgres transaction fails after the neo4j transaction has finished.
def delete_user(%User{} = user) do
Ecto.Multi.new()
|> Ecto.Multi.delete(:delete, user)
|> Ecto.Multi.run(:delete_neo4j, fn _, _ ->
Neo4j.Accounts.delete_user(user)
|> Repo.transaction()
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 17 to 8- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
tjdam
Ohh, tons of food for thought there…! I will begin my experiments this weekend, awesome to know someone around here battle testing it
, will definitely be in contact!
Somewhat related, are you aware of Seraph project?
I found it recently and I was wondering if someone like yourself with some experience handling raw Neo4j queries in production would find it valuable. In particular the idea of an interface that resembles Ecto but it’s built around graph database “mechanics”.
simrayz
Hi there, OP here. Since the start of the year, we’re still using a combination of Neo4J and Postgres. It’s working fine for us, but it does require a lot of low level decisions. In addition, we’ve experienced difficulties when onboarding new employees, as the complexity of running two databases with a custom solution for keeping them synced is hard to grasp. Furthermore, there’s no unified way of writing “migrations” for Neo4j, as it is with ecto. As such, I had to write a script that runs the Neo4j updates manually. Keeping this updated as the business logic changes is a challenge.
If I were to rewrite our backend, I would try my best to use Postgres as much as possible. The reason being that we haven’t yet utilized deep, multi-level queries which are the main selling point for using Neo4j. That being said though, writing Neo4j queries is genuinely fun. Adding a new ad-hoc relationship is done in an instant.
However, we have chosen to use the combination for the foreseeable future. Here’s a few details on our implementation in case you’re interested:
Don’t hesitate with reaching out if you’re interested in knowing more!
tjdam
Yeah, he did mention the issue with drivers, but didn’t expand much on this.
I’m a bit afraid of choosing it due to the current state of its support in Elixir.
Thank you for sharing this, highly useful information
sorentwo
Glenn (and the recorded talk) will have a more accurate memory of the situation than I do, but I’ll share what I can recall.
Much of the data fit into heavily interconnected network of connections, at least for storage. The way that data was used for display and analysis didn’t fit so well. The access pattern was relational, rather than “crawling” through a graph.
The biggest issue, IIRC was with the performance and instability of the Neo4J driver in Ruby. It had concurrency issues and performance bottlenecks that couldn’t easily be worked around. It necessitated backs to correlate PG and Neo4J data and use broad caching layers to prevent ever connecting to the database.
tjdam
Hi @sorentwo! I just watched the talk you linked as I’be been playing with Neo4j and thinking of using it in my next project… but something Glenn mentions in the beginning of the talk is that the mistake they made was they chose to use Neo4j when they believed they were building a social graph when they were not… but what he presents as being the data and relationships they had seems very much like a social graph to me… could you expand on that a little?
Thanks
OvermindDL1
You can even build indexes on json fields. ^.^
PGSQL has ‘path’ based support, I forget the commands off hand but they are in the docs, but those sound better for that use-case?
sorentwo
The talk I linked is about the experience of running an app that combined Postgres and Neo4J. He details the pain points and the extended process to migrate to Postgres entirely.
lpil
I think with Mongo + Neo4j you’ll likely have a lot of the same problems as with Postgres + Neo4j. Mongo vs Postgres is probably a matter of personal preference in many ways, but I would go for Postgres even if I wanted a document database (using Postgres JSONB).
simrayz
Thanks for a lot of good answers!
From what I’ve gathered, using Neo4j as document storage is not the best idea (it doesn’t scale well). However, a lot of projects use a combination of MongoDB as document storage and Neo4j for metadata. I’m thinking that Postgres should be able to fill the role of document storage just as well, as it can store json documents and keep separate fields for what needs to be queryable. Is using Mongo + Neo4j a good idea, and if so, why is this not also the case for Postgres + Neo4j?
The reason for using Neo4j is to simplify modeling of complex structures such as permission hierarchies, as it can be queried and examined exactly as it’s stored, but also to make queries faster when they get several levels deep. I feel like “don’t do it” is a bit of a rash decision, as there’s no doubt that graph databases excel at both these points. However, I can’t find a single record of someone combining Postgres + Neo4j, so I do feel like I’m doing something wrong
sorentwo
Storing data in both Neo4J and Postgres isn’t something I recommend. As mentioned earlier in this thread, something should be the source of truth and then you can replicate to another data store for querying.
There is a great talk on this exact situation by Glen Vanderburg at RailsConf a few years back (this was a project I was initially involved in): https://m.youtube.com/watch?v=Nz-aU3vOFbw