分享表还是不共享? [英] To share a table or not share?

查看:194
本文介绍了分享表还是不共享?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在在我的(beta)网站上,我有一个名为用户数据的表,其中存储名称,哈希(密码),ipaddr,会话密钥,电子邮件和消息号。现在我希望用户拥有个人资料描述,签名,位置(可选),也可能是其他的东西。我应该在一个单独的mysql表中吗?还是应该分享桌子?为什么?

解决方案

这被称为垂直分区,一般来说,无论您选择哪个选项,它都不会有太大差异。



一个垂直分区方法是将很少更新的字段经常更新的字段进行拆分。想象一下Stack Overflow数据库中的 Users 表,具有 User_ID DisplayName 位置等等,然后 UpVotes DownVotes LastSeen NumberOfQuestionsAsked 等。第一组字段很少更改(仅在配置文件编辑中)而另一种分割方式可能是频繁访问的数据之间的数据,很少访问的数据。



在某些特定情况下,这种分区可以产生更好的表现。


Right now on my (beta) site i have a table called user data which stores name, hash(password), ipaddr, sessionkey, email and message number. Now i would like the user to have a profile description, signature, location (optional) and maybe other things. Should i have this in a separate mysql table? or should i share the table? and why?

解决方案

This is called vertical partitioning, and in general it will not make much difference whichever option you go for.

One vertical partitioning method is to split fields that are updated frequently from fields that are updated rarely. Imagine a Users table in Stack Overflow's database, having User_ID, DisplayName, Location, etc... and then UpVotes, DownVotes, LastSeen, NumberOfQuestionsAsked, etc. The first set of fields changes rarely (only on profile edits), while the latter set change frequently (on normal activity).

Another splitting method could be between data that is accessed frequently, from data that is accessed rarely.

This kind of partitioning, in some particular situations, can yield better performance.

这篇关于分享表还是不共享?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆