4

I've used both Neo4j's simple and advanced mapping modes in my Spring Data Neo4j project. Since I've switched from simple to advanced mappings, the project's performance is a lot, and I mean really a lot better than before. I've got no exact numbers to present, but it is for sure a multitude. Can somebody clarify why advanced mapping mode outperforms simple mapping?

I've read the Prorgramming Model page from the SDN documentation, but I couldn't find the exact reason.

For the record, I'm using the @Transactional support from Spring.

tstorms
  • 4,941
  • 1
  • 25
  • 47

2 Answers2

5

Yep that's true, as the advanced mapping is just a thin wrapper around nodes and relationships and writes through to the db (and reads through too). Simple mapping copies data out and in. To keep that performance benefit, use advanced mapping only in transactions and you'll be happy.

If you start modifying entities outside of transactions you will get dirty object tracking and it will start to copy stuff back again.

Michael Hunger
  • 41,339
  • 3
  • 57
  • 80
0

I noticed that with simple mapping there is a lot unnecessary label fetches even though there shouldn't be. Even if you don't use @Fetch, SDN still fetches (for some reason) labels for all nodes in the related Set and in some cases even further that.

For example I had two teams that had around 100 members and the teams were also connected together (as parent-child) and @Fetch was used nowhere, the performance was still awful.

So I switched to advanced mapping to get rid of unnecessary label fetching. In my opinion Simple mapping shouldn't be available anymore, because it works so badly with the new Label based TypeRepresentationStrategy. Seems like it is not developed anymore to suit labels.

Axel Janduneaz
  • 175
  • 1
  • 6