Skip to content

Instantly share code, notes, and snippets.

@danodonovan
Last active January 15, 2018 16:10
Show Gist options
  • Select an option

  • Save danodonovan/1adf3d78cd1e15a963c33d295fb3f345 to your computer and use it in GitHub Desktop.

Select an option

Save danodonovan/1adf3d78cd1e15a963c33d295fb3f345 to your computer and use it in GitHub Desktop.
Handy Neo4j Queries
// count all node labels
MATCH (n)
RETURN labels(n), count(DISTINCT n);
// describe metagraph
CALL db.schema();
// list node stats
// Sample some nodes, reporting on property and relationship counts per node.
MATCH (n) WHERE rand() <= 0.1
RETURN
DISTINCT labels(n),
count(*) AS SampleSize,
avg(size(keys(n))) as Avg_PropertyCount,
min(size(keys(n))) as Min_PropertyCount,
max(size(keys(n))) as Max_PropertyCount,
avg(size( (n)-[]-() ) ) as Avg_RelationshipCount,
min(size( (n)-[]-() ) ) as Min_RelationshipCount,
max(size( (n)-[]-() ) ) as Max_RelationshipCount
@danodonovan
Copy link
Copy Markdown
Author

Switch to queries defined in the Neo4j browser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment