将图存储在MySQL中是一个好主意吗?

时间:2022-10-04 09:37:09

I am using MySQL to store reports from a tool. I am extremely happy with the speed and flexibility with which users can query data. The tool also has some data which is a graph. My question is, is it a good idea to store the graph in MySQL? The number of nodes and edges in the graph is in the millions and queries are usually graph traversals.

我使用MySQL来存储工具的报告。我对用户可以查询数据的速度和灵活性感到非常满意。该工具还有一些数据,这是一个图表。我的问题是,将图存储在MySQL中是个好主意吗?图中的节点和边数以百万计,查询通常是图遍历。

3 个解决方案

#1


5  

MySQL is not created and optimized as a graph database in particular. You might want to try Neo4J which is a good graph database.

特别是MySQL不是作为图形数据库创建和优化的。您可能想尝试Neo4J这是一个很好的图形数据库。

#2


3  

Plain SQL is usually unfit for manipulating a graph datastructure. There are techniques to index it, however.

纯SQL通常不适合操作图数据结构。但是,有一些技术可以对其进行索引。

For instance, if yours is not frequently updated, using a GRIPP index will let you handle graph traversal queries extremely well. The latter lets you answer parent-child and depth-related queries in more or less fixed time -- irrespective of the graph's number of nodes or density of links.

例如,如果您的频繁更新,使用GRIPP索引将使您能够非常好地处理图遍历查询。后者允许您在或多或少的固定时间内回答父子查询和与深度相关的查询 - 无论图的节点数或链接密度如何。

#3


1  

SQL databases don't handle graph data very well in general. The problem is that to do a graph traversal you either have to pull the entire graph into memory in a single query, then manipulate it and store the changes, or you have to perform huge amounts of joins to traverse the graph one node at a time, which becomes prohibitively slow. With graphs of the scale you are looking at it would probably be better to use a graph database or to use a memory database like REDIS as a fast caching layer and then persist it in the background.

SQL数据库通常不能很好地处理图形数据。问题是,要进行图遍历,您必须在单个查询中将整个图拉入内存,然后操纵它并存储更改,或者您必须执行大量连接以一次遍历一个节点的图,这变得非常慢。使用您正在查看的比例图表可能更好的方法是使用图形数据库或使用REDIS等内存数据库作为快速缓存层,然后将其保留在后台。

#1


5  

MySQL is not created and optimized as a graph database in particular. You might want to try Neo4J which is a good graph database.

特别是MySQL不是作为图形数据库创建和优化的。您可能想尝试Neo4J这是一个很好的图形数据库。

#2


3  

Plain SQL is usually unfit for manipulating a graph datastructure. There are techniques to index it, however.

纯SQL通常不适合操作图数据结构。但是,有一些技术可以对其进行索引。

For instance, if yours is not frequently updated, using a GRIPP index will let you handle graph traversal queries extremely well. The latter lets you answer parent-child and depth-related queries in more or less fixed time -- irrespective of the graph's number of nodes or density of links.

例如,如果您的频繁更新,使用GRIPP索引将使您能够非常好地处理图遍历查询。后者允许您在或多或少的固定时间内回答父子查询和与深度相关的查询 - 无论图的节点数或链接密度如何。

#3


1  

SQL databases don't handle graph data very well in general. The problem is that to do a graph traversal you either have to pull the entire graph into memory in a single query, then manipulate it and store the changes, or you have to perform huge amounts of joins to traverse the graph one node at a time, which becomes prohibitively slow. With graphs of the scale you are looking at it would probably be better to use a graph database or to use a memory database like REDIS as a fast caching layer and then persist it in the background.

SQL数据库通常不能很好地处理图形数据。问题是,要进行图遍历,您必须在单个查询中将整个图拉入内存,然后操纵它并存储更改,或者您必须执行大量连接以一次遍历一个节点的图,这变得非常慢。使用您正在查看的比例图表可能更好的方法是使用图形数据库或使用REDIS等内存数据库作为快速缓存层,然后将其保留在后台。