> Am 16.08.2015 um 19:21 schrieb Markus Hofer <[email protected]>:
>
> Please use relationship-types and directions !!!
>
> Even if there is only one relationship type between the objects? I never
> experienced huge performance differences typing the relationships and giving
> them directions.
if the nodes have more relationships then providing those allows neo to load
only subsets from disk never touching the others.
>
> Would be important to see what the execution plans look like
>
> Here we go:
>
> PROFILE
> MATCH (n:Contact)--(:ActivityContact)--(ar:ActivityReport)
> WHERE ar.StartDateTime > 1356994800
> WITH DISTINCT n, COUNT(ar) AS val
> CREATE (s:ScoreFactor {
> name: "ContactActivities123",
> value: val
> })
> CREATE (n)-[:HasScoreFactor]->(s)
>
Ouch that hurts quite a lot (the db-hits). I mean if 10s are ok with you then
fine, otherwise, as this still uses the RULE planner,
Depending on the number of ActivityReports doing the range check takes a while
in 2.2 (it's solved in 2.3)
you can do:
> PROFILE
>
MATCH
> (ar:ActivityReport)
> WHERE ar.StartDateTime > 1356994800
WITH ar
> MATCH (n:Contact)<-[:TYPE?]-(:ActivityContact)<-[:TYPE?]-(ar)
> WITH n, COUNT(distinct ar) AS val
> CREATE (s:ScoreFactor {
> name: "ContactActivities123",
> value: val
> })
> CREATE (n)-[:HasScoreFactor]->(s)
It also depends how many ActivityContacts you have per ActivityReport and if
they are unique or duplicate across all the ActivityReports
otherwise this would also help
MATCH
> (ar:ActivityReport)
> WHERE ar.StartDateTime > 1356994800
WITH ar
> MATCH (ac:ActivityContact)<-[:TYPE?]-(ar)
WITH ac, count(distinct ar) as reports // distinct ac
> MATCH (n:Contact)<-[:TYPE?]-(ac)
> WITH n, SUM(reports) AS val
> CREATE (s:ScoreFactor {
> name: "ContactActivities123",
> value: val
> })
> CREATE (n)-[:HasScoreFactor]->(s)
HTH Michael
> Added 8307 labels, created 8307 nodes, set 16614 properties, created 8307
> relationships, statement executed in 10126 ms.
>
>
> <https://lh3.googleusercontent.com/-fO9zOuzGLhE/VdDGc9hUOjI/AAAAAAAAFxU/FP_NVkPzMi0/s1600/plan.png>
> Btw, how can I export a query plan in text format to paste here?
>
>
> On Sunday, August 16, 2015 at 6:41:10 PM UTC+2, Michael Hunger wrote:
> If that query returns that many rows, depending on the number of
> ActivityReports, I'd query those first and then continue with the rest of the
> query.
>
> Please use relationship-types and directions !!!
>
>>> MATCH (ar:ActivityReport)
>>> WHERE ar.StartDateTime > timestamp()
>
>>> MATCH (n:Contact)--(:ActivityContact)--(ar:ActivityReport)
>>> WITH DISTINCT n, COUNT(ar) AS val
>>> CREATE (s:ScoreFactor {
>>> name: "ContactActivities",
>>> value: val
>>> })
>>> CREATE (n)-[:HasScoreFactor]->(s)
>
> Would be important to see what the execution plans look like
>
> Michael
>
>> Am 16.08.2015 um 18:34 schrieb Markus Hofer <markus...@ <>gmail.com
>> <http://gmail.com/>>:
>>
>> Hi Michael,
>>
>> again, sorry for the late reply.
>> I am using another query now, but I can tell you that the outlined query
>> returned 100K paths.
>> Server had 12G of memory available.
>> Since your mentioned different pattern matching after WITH statements:
>> I am using variables with WITH extensively. Is this recommended or should it
>> rather be avoided?
>>
>> On Monday, July 6, 2015 at 1:05:12 AM UTC+2, Michael Hunger wrote:
>> how many paths does this return?
>>
>> MATCH (n:Contact)--(:ActivityContact)--(ar:ActivityReport) RETURN count(*)
>>
>> the second query causes cypher to use a different pattern matcher (which is
>> suboptimal) but it should not run forever.
>>
>> you can see this if you prefix your queries with PROFILE or EXPLAIN
>>
>>
>>> Am 04.07.2015 um 23:24 schrieb Markus Hofer <markus...@ <>gmail.com
>>> <http://gmail.com/>>:
>>>
>>> The following query works and inserts 8000 nodes in 3 seconds
>>>
>>>
>>> MATCH (n:Contact)--(:ActivityContact)--(ar:ActivityReport)
>>> WHERE ar.StartDateTime > timestamp()
>>>
>>> WITH DISTINCT n, COUNT(ar) AS val
>>> CREATE (s:ScoreFactor {
>>> name: "ContactActivities",
>>> value: val
>>> })
>>> CREATE (n)-[:HasScoreFactor]->(s)
>>>
>>>
>>> However, if I define ANY variable like, the query runs unlimited and does
>>> not insert any node at all.
>>> I think this is a bug.
>>>
>>> WITH timestamp() AS cutoff
>>> MATCH (n:Contact)--(:ActivityContact)--(ar:ActivityReport)
>>> WHERE ar.StartDateTime > cutoff
>>>
>>> WITH DISTINCT n, COUNT(ar) AS val
>>> CREATE (s:ScoreFactor {
>>> name: "ContactActivities",
>>> value: val
>>> })
>>> CREATE (n)-[:HasScoreFactor]->(s)
>>>
>>> --
>>> 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+un...@ <>googlegroups.com <http://googlegroups.com/>.
>>> For more options, visit https://groups.google.com/d/optout
>>> <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
>> <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]
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout
> <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.