Double Negation ? r1 is never null Add a label to n1 Use a Union Look at the query plan with profile
Try this: MATCH (n:`label1`:`label2`) WHERE size( (n)-[:rel1]->() ) = 0 RETURN COUNT(n) AS count; UNION MATCH (n:`label1`:`label2`)-[r1:rel1]->(n1:Label3) WHERE n1.`name` IN ["name1","name2"] RETURN COUNT(n) AS count; On Wed, Apr 20, 2016 at 12:41 AM, <[email protected]> wrote: > I'm using Neo4j 2.3.3. > > The query is very simple: > > neo4j-sh (?)$ MATCH (n:`label1`:`label2`), n-[r1:rel1]->n1 WHERE > (n1.`name` IN ["name1","name2"] OR NOT(r1 IS NOT NULL)) RETURN COUNT(n) AS > count; > +--------+ > | count | > +--------+ > | 462059 | > +--------+ > 1 row > 2894 ms > > > Any ideas on how to improve it? > > -- > You received this message because you are subscribed to the Google Groups > "Neo4j" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
