为什么第一个密码查询比第二个和第三个密码查询速度快得多?
第一次查询:
MATCH (source:Product { product_id:14603 }),
(destination:Product{product_id:286502}),
p = (source-[r]-()-[*0..3]-destination)
RETURN p, length(p) as pathLength LIMIT 50
==> 14秒
==> 50 rows
==>
==> | Operator | Rows | DbHits | Identifiers | Other |
==> +----------------------+------+--------+--------------------------------------------------+---------------------------------------+
==> | ColumnFilter | 50 | 0 | | keep columns p, pathLength |
==> | Slice | 50 | 0 | | { AUTOINT2} |
==> | Extract | 50 | 0 | | pathLength |
==> | ExtractPath | 50 | 0 | p | |
==> | SimplePatternMatcher | 50 | 0 | source, UNNAMED90, destination, r, UNNAMED89 | |
==> | SchemaIndex | 99 | 198 | source, source | { AUTOINT0}; :Product(product_id) |
==> | TraversalMatcher | 99 | 419669 | | UNNAMED89, UNNAMED90, UNNAMED89 |
==> +----------------------+------+--------+--------------------------------------------------+---------------------------------------+
==>
==> Total database accesses: 419867
第二次查询:
MATCH (source:Product { product_id:14603 }),
(destination:Product{product_id:286502}),
p = (source-[r]-()-[*0..2]-destination)
RETURN p, length(p) as pathLength LIMIT 50
==> 140秒
==> 13 rows
==>
==> +----------------------+---------+---------+--------------------------------------------------+---------------------------------------+
==> | Operator | Rows | DbHits | Identifiers | Other |
==> +----------------------+---------+---------+--------------------------------------------------+---------------------------------------+
==> | ColumnFilter | 13 | 0 | | keep columns p, pathLength |
==> | Slice | 13 | 0 | | { AUTOINT2} |
==> | Extract | 13 | 0 | | pathLength |
==> | ExtractPath | 13 | 0 | p | |
==> | SimplePatternMatcher | 13 | 0 | source, UNNAMED90, destination, r, UNNAMED89 | |
==> | SchemaIndex | 2266560 | 4533120 | source, source | { AUTOINT0}; :Product(product_id) |
==> | TraversalMatcher | 2266560 | 2266605 | | UNNAMED89, UNNAMED90, UNNAMED89 |
==> +----------------------+---------+---------+--------------------------------------------------+---------------------------------------+
==>
==> Total database accesses: 6799725
messages.log:
2014-11-26 03:41:18.282+0000 WARN [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 139ms [total block time: 14.49s]
2014-11-26 03:41:20.086+0000 WARN [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 101ms [total block time: 14.591s]
2014-11-26 03:41:29.022+0000 WARN [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 144ms [total block time: 14.735s]
2014-11-26 03:41:43.230+0000 WARN [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 151ms [total block time: 14.886s]
2014-11-26 03:41:45.160+0000 WARN [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 127ms [total block time: 15.013s]
2014-11-26 03:41:48.830+0000 WARN [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 135ms [total block time: 15.148s]
2014-11-26 03:42:01.956+0000 WARN [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 134ms [total block time: 15.282s]
2014-11-26 03:42:05.731+0000 WARN [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 171ms [total block time: 15.453s]
2014-11-26 03:42:07.555+0000 WARN [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 122ms [total block time: 15.575s]
2014-11-26 03:42:13.271+0000 WARN [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 144ms [total block time: 15.719s]
2014-11-26 03:42:36.465+0000 WARN [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 115ms [total block time: 15.834s]
第三次查询:
MATCH (source:Product { product_id:14603 }),
(destination:Product{product_id:286502}),
p = (source-[*0..3]-destination)
RETURN p, length(p) as pathLength LIMIT 50
==>无限运行时间(10分钟后最大化CPU,我重新启动neo4j服务器)
索引:
ON:产品(product_id)ONLINE(用于唯一性约束)
[...]其他一些不是这些查询的相关索引
neo4j.properties
非常感谢提前!
答案 0 :(得分:0)
如果您尝试将每个模式作为单独的MATCH而不是逗号分隔,它会有什么不同吗? e.g。
MATCH (source:Product { product_id:14603 })
MATCH (destination:Product{product_id:286502})
MATCH p = (source-[r]-()-[*0..3]-destination)
RETURN p, length(p) as pathLength LIMIT 50
此外,如果您在/ webadmin运行查询,那么您可以尝试在其前面添加单词' PROFILE'并将其输出粘贴到此处,我将查看它。