Skip to content

Instantly share code, notes, and snippets.

@danodonovan
Last active January 15, 2018 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danodonovan/1adf3d78cd1e15a963c33d295fb3f345 to your computer and use it in GitHub Desktop.
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
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