I have a question regarding the use of LIMIT.
Based on the documentation provided, it looks like we can LIMIT the number of nodes that are handled by a subsequent subquery:
Ex:
If we want to limit the number of updates we can split the query using the WITH clause:
Query
MATCH (n)
WITH n ORDER BY n.name LIMIT 1
SET n.locked = true
RETURN n
Writes locked property on one node and return that node:
If I were to use this strategy to perform a read operation, where I wanted to apply two filters to the data, one to grab an initial dataset, the other to run a more refined query on that portion of a dataset, would this strategy work?
Let's imagine, for example, that I have a bunch of User nodes that are connected to Show nodes that they like. I want to narrow down a set of User nodes based on their location as well as whether or not they like a certain show.
However, I anticipate there being a potentially high volume of users selected based on location, and I don't want to check if all of those users like a show - I want to just check a subset of those users, say 1000 of them.
If I run the following query:
MATCH (u:User {location: $location})
WITH u LIMIT 1000
WHERE u - [:LIKES] -> (s:Show)
RETURN u
Will this portion of the query
WHERE u - [:LIKES] -> (s:Show)
Only run for 1000 user nodes, even if the initial number of nodes selected was far greater?
Thank you!