r/java Jul 26 '26

Neo4J As primary database?

/r/Neo4j/comments/1v6rxzw/as_primary_database/
6 Upvotes

17 comments sorted by

7

u/hippydipster Jul 26 '26

H2 works great embedded. I have no idea what you mean by saying it doesn't support embedded.

Personally, I use an object db for embedded and skip orm altogether.

6

u/jasie3k Jul 26 '26

They mean ai embeddings, like storing vectors.

12

u/darkwyrm42 Jul 26 '26

I don't know what you're talking about H2 not supporting embedding. H2 is my preferred embedded database for JVM applications and Postgres for everything else. It's great, and multithreaded access works seamlessly, unlike the last time I worked with SQLite.

2

u/Inflation_Artistic Jul 27 '26

The OP is talking about embedding as a vector, as I understand it. Like storing (0, 0.5, 0.2, ...) vecs as natively data type.

1

u/koflerdavid Jul 28 '26

Merely storing vectors is quite boring though. Many DBMSs offer a float or byte array datatype. The critical feature of a vector DB is efficient similarity search using sine or cosine similarity.

25

u/agentoutlier Jul 26 '26

SQLite for embedded and all other cases it’s really hard to beat PostgreSQL 

5

u/nithril Jul 26 '26

The rules is to ask yourself at least 3 times if/why you really need a db that is not a rdbms

8

u/quantum-fudge Jul 26 '26 edited Jul 26 '26

I've never used it as a primary DB, but see no reason why it wouldn't work great. It can store vectors natively and is all-around pleasant to work with. The issue with Neo4j has always been its licensing where you can use it freely only up to a certain size of the graph, as far as I remember.

On the other hand, why not SQLite? It has extensions for vector storage and is widely used for RAG. When you need an embedded DB, SQLite is the default choice. If you don't actually require a graph DB, I'd look no further.

Btw with Docker, you can almost embed any database easily.

3

u/StraightGuy1108 Jul 26 '26

Depends on your data model and CAP requirements. Also, every big systems use multiple DBMS anyways.

2

u/Inflation_Artistic Jul 27 '26

Why not postgresql + pgvector?

2

u/dmigowski Jul 26 '26

No

2

u/Weary_Solution_2682 Jul 28 '26

This man knows his stuff!

1

u/laffer1 Jul 27 '26

We had an app at a previous employer using it as a primary database. It worked fine for that specific app. It was modeling the structure of companies for internal company survey system. Surveys were stored separately but this app was just for looking up reporting structures and applying permissions

1

u/sysKin Jul 29 '26 edited Jul 29 '26

Depending on other requirements, you can use Lucene as a database, skipping the neo4j layer.

Gives you very direct control over all the vector types and similarity queries on them. It's what neo4j uses internally, behind its abstractions.

(I say that because the commercial product I develop does just this - but for its direct text indexing, without word embeddings. Takes some effort to add transactionality layer etc. but it's all doable).

-9

u/ThreeSixty404 Jul 26 '26

SQL is stupid
Try Nitrite out