Thanks Michael!

~A

On Mon, Oct 13, 2014 at 6:57 PM, Michael Hunger <
michael.hun...@neotechnology.com> wrote:

> The more recent versions use and index for your IN query, so it will
> actually use an index or constraint in this case, that fix was added after
> 2.0.3 though.
>
>
>
> On Mon, Oct 13, 2014 at 11:33 PM, Aru Sahni <arusa...@gmail.com> wrote:
>
>> Hi,
>>
>> Disclaimer: I'm using Neo4j 2.0.3. I know that this is far from the most
>> recent version, but a bug between the latest stable py2neo and 2.1.x
>> builds have me stuck on this release
>> <https://groups.google.com/forum/#!topic/neo4j/-eqzLPxk0DI>.
>>
>> I'm writing an ETL script that needs to retrieve around 500 nodes per
>> request.  My nodes have a `uid` field that is indexed and has a
>> uniqueness constraint.
>>
>> :Entity(uid)
>>
>> To get these nodes, I'm issuing the following query:
>>
>> MATCH (n:Entity)
>> WHERE n.uid IN ["uid001", "uid002" ... "uid500"]
>> RETURN n ORDER BY ID(n) ASC;
>>
>> This takes quite a bit of time. Running this with the profiler indicates
>> that it's hitting the database for every filter.  Attempting to unroll this
>> (i.e. `WHERE n.uid = "uid001" OR n.uid = "uid002"`, etc) hits the
>> database just as heavily. If I try to specify the index with the USING
>> statement, I get the following error:
>>
>> IndexHintException: Cannot use index hint in this context. Index hints
>>> require using a simple equality comparison in WHERE (either directly or as
>>> part of a top-level AND).
>>>
>>
>> What I find ends up working is:
>>
>> MATCH (n:Entity) WHERE n.uid = "uid001" RETURN n
>> UNION ALL
>> MATCH (n:Entity) WHERE n.uid = "uid002" RETURN n
>> ...
>> MATCH (n:Entity) WHERE n.uid = "uid500" RETURN n
>>
>> This is a little too verbose and hacky for my tastes. I was wondering if
>> there's anything I can do to improve the performance and reduce the
>> complexity of this query.
>>
>> Regards,
>> ~Aru
>>
>> --
>> 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 neo4j+unsubscr...@googlegroups.com.
>> 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 neo4j+unsubscr...@googlegroups.com.
> 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 neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to