How Does the Neo4j Range Index BTREE work after deletion of nodes

34 Views Asked by At

I have a query that matches few nodes each time it runs.This query runs around 50,000 times in my program.After which I have designed a loop to delete the nodes that i have matched in a separate query .Each match and delete query is within a block of code that runs around 50,000 times.Considering I have created indexes for all the nodeLabels on the property that i am using to query the nodes,how will the presence of a query affect performance. After testing it for myself I have observed that time taken for the program to run is more after index creation when compared to running it before the creation of index. Is this possible? Shouldn't indexes improve the performance.

I have read that range indexed work internally using a BTree.Does the BTree get modified after each delete? Is that the reason for time increase?

1

There are 1 best solutions below

0
Finbar Good On

If I understand you correctly, you are measuring the performance of the MATCH and the DELETE of the matched nodes. As it says in the docs here, that shouldn't be surprising, as indexes will slow down writes:

Slower write queries: adding indexes impacts the performance of write queries. This is because indexes are updated with each write query. If a system needs to perform a lot of writes quickly, it may be counterproductive to have an index on the affected data entities. In other words, if write performance is crucial for a particular use case, it may be beneficial to only add indexes where they are necessary for read purposes.