Neo4j Performance Issue while creating relationship on existing nodes? -
indexes products:
- on: products(saleid)
- on: products(countryid)
- on: products(productid)
- on: products(id)
- few more properties...
indexes orders:
- on: orders(saleid)
- on: orders(countryid)
- on: orders(productid)
- on: orders(id)
- few more properties...
product has 50k nodes
orders has 500k nodes
when create relation on above scenarios on existing nodes. takes 15 mins in community version 3.1.
query:
match(prod:products) prod.id = 999 prod match (ord:orders) ord.id = prod.id , ord.saleid=prod.saleid , ord.countryid = prod.countryid , ord.productid = prod.productid create (prod)-[prod_ord]->(ord)
current conig:
ram - 64g heap max = min = 32 page swap = default/auto
db hit -> 500 million hits
q1. not considering indexes, how force considering indexing via following indexes?
using index on prod:product(saleid)
using index on prod:product(productid)
using index on prod:product(countryid)
using index on prod:product(id)
q2. why take time? configuration needs done? or data model wrong?
your query uses products
label, index on product
.
also extract product id parameter , use in second match. should use orders(id)
index:
match (prod:products) prod.id = {prodid} prod match (ord:orders) ord.id = {prodid} , ord.saleid=prod.saleid , ord.countryid = prod.countryid , ord.productid = prod.productid create (prod)-[prod_ord]->(ord)
you can set parameter in browser
:param prodid : 999
the other indexes not useful, because doing lookup on 1 property , filter results faster using multiple lookups , doing kind of join. if of properties more unique use instead.
Comments
Post a Comment