[英]Improving DB Efficiency for Attribute / Value Table
每个月,我处理大约500万个信用报告,每个报告包含大约1600个属性,大小从smallint
到Varchar(1000)
。
这些信用报告属性因信用提供者而异。
我正在寻找有关如何更好地改进下面捕获信用数据的架构的任何建议:
credit_reports
- id (int, PK)
- credit_report_provider_id (int, FK)
credit_report_attributes
- id (int, PK)
- credit_report_id (int)
- attribute (varchar(10))
- value (varchar(1000))
credit_report_providers
- id (int, PK)
- name (varchar(15))
我主要关心的是在credit_report_attributes
表中使用Entity-Value-Attributes设计。
数百个属性是tinyints
,但由于这个表需要足够通用以支持任意数量的属性和值类型/长度,我担心这会导致性能问题,因为这个表快速增长。
是否有其他方法可以让我更有效地从多个不同的信用报告提供商处获取信用报告属性?
另一种方法是在属性表中使用属性类型列,然后将tiny int属性拆分为一个表,将更多基于字符串的属性拆分为另一个表。 但这取决于您的查询方式和索引模型。
例如:
credit_reports
- id (int, PK)
- credit_report_provider_id (int, FK)
credit_report_attributes_int
- id (int, PK)
- credit_report_id (int)
- attribute (varchar(10))
- value (tinyint)
credit_report_attributes_string
- id (int, PK)
- credit_report_id (int)
- attribute (varchar(10))
- value (varchar(1000))
credit_report_providers
- id (int, PK)
- name (varchar(15))
credit_report_providers_attributes
- credit_report_provider_id (int, FK)
- typeid (int, PK)
- name (varchar(15))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.