Help with validating Use for RedisGraph

I’m working on an App that will rely on a friends Graph, which should have a recommendation feature that recommends other people based on your friends graph. Another key feature is searching by username, firstname & lastname.
I know that RedisGraph could support the search feature by using the STARTS WITH operation on the labels of the user node. But I’m not sure if I should use RedisGraph to also store labels rather then just the relations of users, because increased memory and storage footprint = higer cost.
Does memory and storage increase a lot when adding 3 labels to a node, seen on a large number of nodes?

I currently have designed a system where the user data is stored in a seperate mySQL DB and RedisGraph would only reference the ids & relations of the user. The search would then be run over the data in mySQL. But with that design it would introduce more latency when incorporating friend relations into ranking search results. Because we would first have to get the id of all/some friends of a user and query the mySQL data to return only users who match one of the ids but also the query string.

Another solution would be to also store the searchable data in RedisGraph and keep it in sync with the mySQL DB, that way we can filter by relations & a search string with one query in RedisGraph. And directly use the returned ids to get all associated user information.

What system would you recommend? Either optimize for cost by keeping relations and the rest of user information completely separate or copy data in two places? Or am I judging RedisGraph wrong in it’s ability to store labels efficiently.

Each label will have a corresponding matrix of node_count X node_count dimensions, so they can be costly. If memory is a concern, I’d recommend sticking to a single label and storing the other two as properties on the node.

I don’t fully understand the system you’ve laid out, but storing relations and search strings in RedisGraph sounds a lot more convenient to me!

I think I misunderstood the meaning of labels. I would store the username, firstname and lastname as properties of the node. I thought properties and labels were the same.
Is it possible to set the id of the node or is it always autogenerated? If I could define the id myself then I could reuse the mySQL id (also an integer) and save up one extra property which I would otherwise have to set on the Node to identify the associated user information in mySQL.

Hi Jonas,
Labels can be though of as the TYPE of the node, e.g. User, Workplace, Location…
Attributes are metadata associated with a graph entity: (node, edge)

Adding multiple attributes to an entity is extremely common, I wouldn’t expect an enormous increase in memory, but it really depends on your data, my suggestion for you is to simply try it out,

In addition I’ll suggest creating an index over the attributes you’ll be filter by, see here

With regard to IDs, these are auto-generated, but you can introduce an id attribute for each entity, just make sure it is indexed.

1 Like