我们公司正在开发一个内部项目来解析文本文件。这些文本文件由使用常规表达式提取的元数据组成。十台计算机 24/7 全天候解析文本文件,并为高端 Intel Xeon SQL Server 2005 数据库提供提取的元数据。
简化的数据库模式如下所示:
项目 | 身份证 | 姓名 | |----|--------| | 1 | 样品 |
Items_Attributes | 项目 ID | 属性 ID | |--------|-------------| | 1 | 1 | | 1 | 2 |
属性 | 身份证 | 属性类型 ID | 价值 | |----|-----------------|--------| | 1 | 1 | 500MB | | 2 | 2 | 1.0.0 |
属性类型 | 身份证 | 姓名 | |----|---------| | 1 | 尺寸 | | 2 | 版本 |
有许多不同的文本文件类型,里面有不同的元数据。对于每个文本文件,我们都有一个Item
,对于每个提取的元数据值,我们都有一个Attribute
.
Items_Attributes
allow us to avoid duplicate Attribute
values which avoids database size to increase x^10.
This particular schema allows us to dynamically add new regular expressions and to obtain new metadata from new processed files no matter which internal structure they have.
Additionally this allow us to filter the data and to obtain dynamic reports based on the user criteria. We are filtering by Attribute
and then pivoting the resultset (http://msdn.microsoft.com/en-us/library/ms177410.aspx). So this example pseudo-sql query
SELECT FROM Items WHERE Size = @A AND Version = @B
would return a pivoted table like this
| ItemName | Size | Version |
|----------|-------|---------|
| Sample | 500mB | 1.0.0 |
The application has been running for months and performance decreased terribly at the point is no longer usable. Reports should take no more than 2 seconds and Items_Attributes
table 每周平均增加 10,000,000 行。一切都已正确索引,我们花费了大量时间分析和优化查询执行计划。
所以我的问题是,您将如何扩展它以减少报告执行时间?
我们提出了这个可能的解决方案:
- 购买更多硬件并设置 SQL Server 集群。(我们需要关于正确的“集群”策略的建议)
- 使用像 HBase 这样的键/值数据库(我们真的不知道是否能解决我们的问题)
- 使用 ODBMS 而不是 RDBMS(我们一直在考虑 db4o)
- 将我们的软件迁移到云端(我们的经验为零)
- 在运行时静态生成报告。(我们真的不想)
- 常见报表的静态索引视图(性能几乎相同)
- 非规范化架构(我们的一些报告在单个查询中涉及多达 50 个表)