<p dir="auto">Both rule and cost query planners implement</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="MATCH n
WHERE n:Male
RETURN n"><pre class="notranslate"><code class="notranslate">MATCH n
WHERE n:Male
RETURN n
</code></pre></div>
<p dir="auto">with a <code class="notranslate">NodeByLabelScan</code> and not with an <code class="notranslate">AllNodesScan</code> plus a filter on the label. I therefore would expect</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="MATCH n
WHERE n:Male OR n:Female
RETURN n"><pre class="notranslate"><code class="notranslate">MATCH n
WHERE n:Male OR n:Female
RETURN n
</code></pre></div>
<p dir="auto">to be implemented with two <code class="notranslate">NodeByLabelScan</code>'s. Instead both planners use an <code class="notranslate">AllNodesScan</code> and then a filter.</p>
<p dir="auto">For a simple label disjunction like this, would it not be possible and prudent for the planners to implement the query with label scans?</p>
<p dir="auto">Related <a href="http://stackoverflow.com/questions/20003769/neo4j-match-multiple-labels-2-or-more" rel="nofollow">SO question</a>.</p>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/gokcemutlu/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/gokcemutlu">@gokcemutlu</a>: 'Hi,</p>
<p dir="auto">I have a simple model:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="START root=node(0) CREATE UNIQUE root-[:PEOPLE]-&gt;(jake {Name:'Jake'}), root-[:PEOPLE]-&gt;(jill {Name:'Jill'}), jake-[:LIKE]-&gt;jill, jill-[:LIKE]-&gt;jake, jake-[:LIKE]-&gt;jake;"><pre class="notranslate"><code class="notranslate">START root=node(0) CREATE UNIQUE root-[:PEOPLE]-&gt;(jake {Name:'Jake'}), root-[:PEOPLE]-&gt;(jill {Name:'Jill'}), jake-[:LIKE]-&gt;jill, jill-[:LIKE]-&gt;jake, jake-[:LIKE]-&gt;jake;
</code></pre></div>
<p dir="auto">In this model</p>
<ul dir="auto">
<li>Jake likes Jill,</li>
<li>Jill likes Jake</li>
<li>Jake likes Jake</li>
</ul>
<p dir="auto">I want to find out Jake likes who.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="START r = node(0) MATCH r-[:PEOPLE]-&gt;jake, path=(jake-[:LIKE]-&gt;person-[:LIKE]-&gt;jake) where jake.Name = 'Jake' RETURN person;"><pre class="notranslate"><code class="notranslate">START r = node(0) MATCH r-[:PEOPLE]-&gt;jake, path=(jake-[:LIKE]-&gt;person-[:LIKE]-&gt;jake) where jake.Name = 'Jake' RETURN person;
</code></pre></div>
<p dir="auto">This query returns only Jill and this is wrong.</p>
<p dir="auto">Please let me know.</p>
<p dir="auto">Regards,<br>
Gokce'</p>