cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Understanding "IN" operator

lcl_ct2
Node Link

I need help in understanding the IN operator

In my following example:

MATCH (a1:Author)-[co:COAUTHOR]-(a2:Author) WHERE co.year IN [2017,2018,2019,2020] RETURN a1,co,a2

The operator tests every year every time in array to compute a MATCH OR tests each year in array by index (starting from 2017 THEN going to 2018 ... 2020)

Im in doubt if need to use some logic to iterate the array of years, in this example, to compute the required MATCH.

1 ACCEPTED SOLUTION

anthapu
Graph Fellow

For relationship there is no index, so it gets all relationships first and then checks if the year is in the list provided.

If you try profiling you will see a DB scan.

Say if the year is an attribute on Author node and you have index on year then it would use index based look up similar to

year=2017 or year=2018 or year=2019 or year=2020.

Hope that makes it clear.

View solution in original post

2 REPLIES 2

anthapu
Graph Fellow

For relationship there is no index, so it gets all relationships first and then checks if the year is in the list provided.

If you try profiling you will see a DB scan.

Say if the year is an attribute on Author node and you have index on year then it would use index based look up similar to

year=2017 or year=2018 or year=2019 or year=2020.

Hope that makes it clear.

Thanks for explanation, now i understand better.