I asked the same question on Slack and they suggested me to move the discussion on Neo4j Community.
How to optimize below Cypher?
PROFILE
MATCH (port:PhysicalPort) WHERE NOT (1 IN port.latest) WITH port
MATCH (device:Device) WHERE NOT (1 IN ...
latest is a property in all Nodes, which is of type array. Currently, it has values [ 1, 2 ] or [ 2, 3, 4] and I want to filter those records where this array doesn't have value 1.