Skip to content

Instantly share code, notes, and snippets.

@systay
Created November 20, 2014 08:05
Show Gist options
  • Save systay/4ecc078c3c353a957048 to your computer and use it in GitHub Desktop.
Save systay/4ecc078c3c353a957048 to your computer and use it in GitHub Desktop.
neo4j-sh (?)$ profile match (writer:Entity{ Id:"77e452da060a4e09b7d0d5fae20aca82" }), writer-[:wrote]->segment-[r1:regarding_entity]->entity
> with entity as names, count(entity) as counts
> order by count(entity) desc
> limit 100 with names, counts
> match otherwriters-[:wrote]->segment-[r2:regarding_entity]->names
> return otherwriters.Name as Name, otherwriters.Id as Id, count(distinct names) as EntityCount
> order by count(distinct names) desc skip 1 limit 3;
+----------------------------------------------------------------------+
| Name | Id | EntityCount |
+----------------------------------------------------------------------+
| "Matthew Lenhart" | "f3424f4f6fcd404286fb6c2219705020" | 47 |
| "Jeff Dasovich" | "ce2bdd854efc4730ae1e459e687e6f3c" | 47 |
| "Empty Sender" | "20d2daf3d8174ab19dfd31f3664fbf60" | 46 |
+----------------------------------------------------------------------+
3 rows
398 ms
Compiler CYPHER 2.2-cost
Skip
|
+Top(0)
|
+EagerAggregation(0)
|
+Projection(0)
|
+Expand(0)
|
+Expand(1)
|
+Top(1)
|
+EagerAggregation(1)
|
+Projection(1)
|
+Expand(2)
|
+Expand(3)
|
+NodeIndexSeek
+---------------------+---------------+-------+--------+----------------------------------------------------------+---------------------------------------------+
| Operator | EstimatedRows | Rows | DbHits | Identifiers | Other |
+---------------------+---------------+-------+--------+----------------------------------------------------------+---------------------------------------------+
| Skip | 0 | 3 | 0 | EntityCount, Id, Name | { AUTOINT2} |
| Top(0) | 0 | 4 | 0 | EntityCount, Id, Name | Add({ AUTOINT3},{ AUTOINT2}); EntityCount |
| EagerAggregation(0) | 0 | 9218 | 0 | EntityCount, Id, Name | Name, Id |
| Projection(0) | 0 | 56406 | 225624 | segment@255, Id, Name, counts, names, otherwriters, r2 | Name, Id, names |
| Expand(0) | 0 | 56406 | 112812 | segment@255, counts, names, otherwriters, r2 | ( segment@255)<-[:]-(otherwriters) |
| Expand(1) | 0 | 56406 | 56506 | segment@255, counts, names, r2 | (names)<-[:r2]-( segment@255) |
| Top(1) | 0 | 100 | 0 | counts, names | { AUTOINT1}; counts |
| EagerAggregation(1) | 0 | 485 | 0 | counts, names | names |
| Projection(1) | 0 | 576 | 0 | segment@81, entity, names, r1, writer | names, entity |
| Expand(2) | 0 | 576 | 710 | segment@81, entity, r1, writer | ( segment@81)-[:r1]->(entity) |
| Expand(3) | 0 | 134 | 135 | segment@81, writer | (writer)-[:]->( segment@81) |
| NodeIndexSeek | 0 | 1 | 2 | writer | :Entity(Id) |
+---------------------+---------------+-------+--------+----------------------------------------------------------+---------------------------------------------+
Total database accesses: 395789
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment