惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Palo Alto Networks Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
S
Schneier on Security
S
Securelist
酷 壳 – CoolShell
酷 壳 – CoolShell
C
CXSECURITY Database RSS Feed - CXSecurity.com
Cyberwarzone
Cyberwarzone
Apple Machine Learning Research
Apple Machine Learning Research
S
SegmentFault 最新的问题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
GbyAI
GbyAI
Security Latest
Security Latest
Last Week in AI
Last Week in AI
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
Recorded Future
Recorded Future
Webroot Blog
Webroot Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
TaoSecurity Blog
TaoSecurity Blog
C
Cisco Blogs
博客园 - 【当耐特】
Blog — PlanetScale
Blog — PlanetScale
Hugging Face - Blog
Hugging Face - Blog
B
Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Attack and Defense Labs
Attack and Defense Labs
The Last Watchdog
The Last Watchdog
U
Unit 42
阮一峰的网络日志
阮一峰的网络日志
Project Zero
Project Zero
WordPress大学
WordPress大学
L
LINUX DO - 最新话题
F
Fortinet All Blogs
L
LINUX DO - 热门话题
PCI Perspectives
PCI Perspectives
Simon Willison's Weblog
Simon Willison's Weblog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MongoDB | Blog
MongoDB | Blog
Latest news
Latest news
P
Proofpoint News Feed
T
Threat Research - Cisco Blogs
The Hacker News
The Hacker News
爱范儿
爱范儿
O
OpenAI News
J
Java Code Geeks
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - 超晨

jacob的使用方法 飞秋软件的OA消息接口服务器 c#关于数据库自定义类型在存储过程中返回服务器端的问题 vs2010 sp1在win2003不能安装的问题 jquery插件Uploadify使用中的注意事项 adsl拨号vpn后,adsl就不能用了 - 超晨 坑爹啊!!!win2003 x64企业版不支持tfs2010的源代码管理服务 mysql真是不错! gui设计禁忌2.0读书笔记 tfs2010中文版下载 iisExpress的设置 vs08+ie8开发遇到的问题 sql命令行添加一个登陆给某数据库,并给予指定角色(备忘) 消除数据库JS入侵的脚本 数据绑定到分页的快速开发最佳实践 dataset绑定翻页和泛型+实体类绑定翻页的性能比较 Windows 远程桌面不能连接解决办法zt Python企业应用的优缺点(zt) python应用领域介绍 (zt)
SQL冗余字段的策略和管理
超晨 · 2009-11-22 · via 博客园 - 超晨

      冗余字段的使用在多表联合查询都是大数据量的表的情况下,确实是个不错的选择,有效的减少了IO操作。但结合已有的项目产品来看,冗余字段确实是双刃剑。尤其是大项目的开发,如果忽略某个表的冗余字段的更新,那么后果是灾难性的。如何有效的管理冗余字段是开发组内必须解决的问题。我的解决方案是:使用专门的表来管理冗余字段。例如article表有以下冗余字段

fromUserName,toUserName

如何管理这两个字段呢?通过建立一个表,表结构如下
id,objTable,objName,sourceTable, sourceId,level,isUpdate

其中objTable=目标表,objName= 目标字段,sourceTable=源表,sourceId=源表ID,level=是否需要立即更新,isUpdate=是否已更新

其中,level字段很有必要,有些冗余字段并不需要在源表修改后立即更新,那么可以通过一个定期更新策略来更新。

 通过库表的管理,配合一个合理的存储过程,冗余字段的使用将不再是难题。

举例,如果上面两个字段发生变化,则使用触发器或者调用这个存储过程来检查是否有需要立即更新的冗余字段,需要则立即更新,不需要则isUpdate置0,等到周期性的策略来更新同时isUpdate=1。

如果项目中使用了memcache,则还可以使用另一个思路来进一步减小数据库IO操作。下篇再展开来说。