scholrly / neo4django

Drop-in Neo4j/Django integration.
GNU General Public License v3.0
357 stars 83 forks source link

Query optimisation: where should I look for? #253

Open pirhoo opened 10 years ago

pirhoo commented 10 years ago

Hi @mhluongo,

we encounter some slowness with Neo4django. According the access log I noticed that the ORM does a lot of requests to load the Model schema from Neo4j. I understand why we need to do that schema but don't you think we could cache this in any way? If yes, I'll be happy to give it a try but I don't know where should I look first.

Very best, P

mhluongo commented 10 years ago

@Pirhoo sorry for the long silence on this. Honestly, I think the best way to speed up this stuff would be to focus more heavily on the scripting, and eschew the use of neo4j-rest-client's pure-REST for basic models- or at least introduce some discipline. For example, it takes a few calls to create a new node, instead of one- partly because we blindly rely on the underlying client, and don't think about what triggers an update.

Type nodes, etc are definitely a target for caching. Some happens already, but clearly not enough. A good place to start is https://github.com/scholrly/neo4django/blob/master/neo4django/db/models/base.py#L392. Though moving to Neo4j 2+ would let this be replaced by schemas instead of an in-graph type hierarchy.