时间和地理位置数据的数据库设计
Database design for time and geolocation data
我已经成功实现了文档中显示的 Time Series Use case。最小时间单位指向的数据(Event class)用lucene空间索引进行索引。
我有两种类型的活动:私人活动或 public。
我应该如何为我的用例设计我的数据库和集群?
使用 Edge 还是 linklist 来使 link 从 Min 到 Event 更好?
担心以后我的lucene空间索引会太大
通过阅读文档,使用 clusters 地理定位数据似乎是一个很好的策略。
可以只在子查询上使用索引:
select
from
(select
expand(month["12"].day["25"].hour["17"].min["07"].events)
from
Year
where
year = 2015)
where
[lat,lng,$spatial]
NEAR
[66,66,{"maxDistance":1}]
关于索引的文档告诉我可以使用 indexes on an edge properties。不利的一面是它占用的存储空间比 linked 列表我测试过它并且有效:
select
expand(inV())
from
(select
expand(month["12"].day["25"].hour["17"].min["07"].outE('MinPublicEvent'))
from
Year
where
year = 2015)
where
[lat,lng,$spatial]
NEAR
[66,66,{"maxDistance":1}]
关于边缘与 link,取自 OrientDB doc: lightweight edges,第一个区别是边缘可以存储属性而 links 不能。
These are the PROS and CONS of Lightweight Edges vs Regular Edges:
PROS:
faster in creation and traversing, because don't need an additional
document to keep the relationships between 2 vertices
CONS:
cannot store properties harder working with Lightweight edges from
SQL, because there is no a regular document under the edge
既然你已经提到在边上使用属性,这对我来说很有意义,因为你可以在边上使用这些属性来横向图形,这意味着你不能使用 link 来存储这种关系。
如果您想将这些属性嵌入事件顶点,那也很好,您可以使用 links,失去在边缘使用属性的能力横向图表以提高性能。
edge 方法更具表现力,但当性能非常重要并且存在瓶颈风险时,您应该监控指标和性能,并重构为 embed + link 方法以防出现瓶颈是性能问题。
更新:
集群基本上是一种在 OrientDB (Clusters tutorial) 中拆分数据的机制,它适用于边缘和顶点。
You may also find it beneficial to locate different clusters on
different servers, physically separating where you store records in
your database. The advantages of this include:
- Optimization: Faster query execution against clusters, given that you
need only search a subset of the clusters in a class.
- Indexes: With good partitioning, you can reduce or remove the use of > indexes.
- Parallel Queries: Queries can be run in parallel when made to data on
multiple disks.
- Sharding: You can shard large data-sets across
multiple instances.
除非你能清楚地识别出一个很好的数据分区方式,并且可以在不同的服务器之间分布你的数据库,否则我建议你从默认开始,因为 OrientDB 已经为每个 class 创建了 1 个集群架构,并随着数据库的增长添加更多集群。
何时添加更多集群?指标,指标和指标。跟踪您的应用程序如何访问您的数据库、查询类型、查询量等。
我已经成功实现了文档中显示的 Time Series Use case。最小时间单位指向的数据(Event class)用lucene空间索引进行索引。
我有两种类型的活动:私人活动或 public。
我应该如何为我的用例设计我的数据库和集群?
使用 Edge 还是 linklist 来使 link 从 Min 到 Event 更好?
担心以后我的lucene空间索引会太大
通过阅读文档,使用 clusters 地理定位数据似乎是一个很好的策略。
可以只在子查询上使用索引:
select
from
(select
expand(month["12"].day["25"].hour["17"].min["07"].events)
from
Year
where
year = 2015)
where
[lat,lng,$spatial]
NEAR
[66,66,{"maxDistance":1}]
关于索引的文档告诉我可以使用 indexes on an edge properties。不利的一面是它占用的存储空间比 linked 列表我测试过它并且有效:
select
expand(inV())
from
(select
expand(month["12"].day["25"].hour["17"].min["07"].outE('MinPublicEvent'))
from
Year
where
year = 2015)
where
[lat,lng,$spatial]
NEAR
[66,66,{"maxDistance":1}]
关于边缘与 link,取自 OrientDB doc: lightweight edges,第一个区别是边缘可以存储属性而 links 不能。
These are the PROS and CONS of Lightweight Edges vs Regular Edges:
PROS:
faster in creation and traversing, because don't need an additional document to keep the relationships between 2 vertices
CONS:
cannot store properties harder working with Lightweight edges from SQL, because there is no a regular document under the edge
既然你已经提到在边上使用属性,这对我来说很有意义,因为你可以在边上使用这些属性来横向图形,这意味着你不能使用 link 来存储这种关系。
如果您想将这些属性嵌入事件顶点,那也很好,您可以使用 links,失去在边缘使用属性的能力横向图表以提高性能。
edge 方法更具表现力,但当性能非常重要并且存在瓶颈风险时,您应该监控指标和性能,并重构为 embed + link 方法以防出现瓶颈是性能问题。
更新:
集群基本上是一种在 OrientDB (Clusters tutorial) 中拆分数据的机制,它适用于边缘和顶点。
You may also find it beneficial to locate different clusters on different servers, physically separating where you store records in your database. The advantages of this include:
- Optimization: Faster query execution against clusters, given that you need only search a subset of the clusters in a class.
- Indexes: With good partitioning, you can reduce or remove the use of > indexes.
- Parallel Queries: Queries can be run in parallel when made to data on multiple disks.
- Sharding: You can shard large data-sets across multiple instances.
除非你能清楚地识别出一个很好的数据分区方式,并且可以在不同的服务器之间分布你的数据库,否则我建议你从默认开始,因为 OrientDB 已经为每个 class 创建了 1 个集群架构,并随着数据库的增长添加更多集群。
何时添加更多集群?指标,指标和指标。跟踪您的应用程序如何访问您的数据库、查询类型、查询量等。