Return sum(length(p)-1) Sent from mobile device
Am 03.07.2014 um 20:26 schrieb jankan99 <[email protected]>: > Hello, > > Thank you. I did upgrade to 2.1.2. When i tried the below statement, the > queries are coming back really fast but since i am using the allshortestpath, > I believe all the nodes including a and c are included in the count. I just > need the nodes that are in the path between a and c. > > Is there are way to get ONLY the count of nodes between the nodes a and c? > > Thank you for the help. > > Raj > > On Wednesday, July 2, 2014 1:36:04 PM UTC-7, Michael Hunger wrote: >> >> If you update to 2.1.2 it uses indexes for IN clauses. >> >> And you might be able to do >> >>> match (a:newtags) where a.name IN >>> ["1225","10091","1921056","11962","1921078","1920809","1921090"] >>> match (c:newtags) where c.name IN ["5226","1955"] >>> match p = allShortestPaths((a)-[*..2]-(c)) >>> return count(*) >> >> >> Use the profile keyword in the neo4j shell to see if it actually uses an >> index: >> >> like this: >> >> profile >> > match (a:newtags) where a.name IN >> > ["1225","10091","1921056","11962","1921078","1920809","1921090"] >> > match (c:newtags) where c.name IN ["5226","1955"] >> > match p = allShortestPaths((a)-[*..2]-(c)) >> > return count(*) >> > ; >> +----------+ >> | count(*) | >> +----------+ >> | 0 | >> +----------+ >> 1 row >> >> ColumnFilter >> | >> +EagerAggregation >> | >> +ShortestPath >> | >> +SchemaIndex(0) >> | >> +SchemaIndex(1) >> >> +------------------+------+--------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+ >> | Operator | Rows | DbHits | Identifiers | >> >> Other | >> +------------------+------+--------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+ >> | ColumnFilter | 1 | 0 | | >> >> keep columns count(*) | >> | EagerAggregation | 1 | 0 | | >> >> | >> | ShortestPath | 0 | 0 | p | >> >> | >> | SchemaIndex(0) | 0 | 0 | c, c | >> Collection(List({ >> AUTOSTRING7}, { AUTOSTRING8})); :newtags(name) | >> | SchemaIndex(1) | 0 | 7 | a, a | Collection(List({ >> AUTOSTRING0}, { AUTOSTRING1}, { AUTOSTRING2}, { AUTOSTRING3}, { >> AUTOSTRING4}, { AUTOSTRING5}, { AUTOSTRING6})); :newtags(name) | >> +------------------+------+--------+-------------+---------------------------------------------------------------------------------------------------------------------------------------------------------+ >> >> You should also pass in your collections as parameters, so the query can be >> built once and then reused >> >>> match (a:newtags) where a.name IN {tags1} >>> match (c:newtags) where c.name IN {tags2} >>> match p = allShortestPaths((a)-[*..2]-(c)) >>> return count(*) >> >> >> >> Michael >> >> Am 02.07.2014 um 17:10 schrieb jankan99 <[email protected]>: >> >>> Hello, In the 2.1.1 version, when we do the following cypher it takes a >>> long time (more than a minute). When we do the same query using a "With" >>> clause, it takes about 6 seconds. We need to get this down to less than a >>> second. We think it is slow because all the nodes "a" and "c" are loaded >>> in memory before filtering is done using the "where" clause. Is there >>> anyway to force Neo to use the indexes on the "name" property to select >>> only the nodes in the where clause. We tried USING HINTS but it looks the >>> IN clause is not supported for hints. >>> >>> Cyoher that takes more than a minute >>> match (a:newtags)-[:belongs_to]-(b)-[:belongs_to]-(c:newtags) >>> where a.name IN >>> ["1225","10091","1921056","11962","1921078","1920809","1921090"] >>> and c.name IN ["5226","1955"] >>> return count(distinct(b)); >>> >>> Cypher using WITH clause takes about 6 seconds >>> match (a:newtags) where a.name IN >>> ["1225","10091","1921056","11962","1921078","1920809","1921090"] >>> with a >>> match (a)-[rm1]-(b)-[rm2]-(c:newtags) >>> where c.name IN ["5226","1955"] >>> return (count(distinct(b)) >>> >>> Some stats: >>> The machine has about 2.2 milion nodes. We are using AWS with 7.5 GB RAM. >>> >>> Any help will be appreciated. >>> >>> Thank you. >>> >>> Raj >>> >>> >>> -- >>> 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. -- 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.
