数据库效率 - 每个用户的表与用户的表 [英] Database efficiency - table per user vs. table of users

查看:95
本文介绍了数据库效率 - 每个用户的表与用户的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于拥有用户的网站。每个用户都有能力创建任何数量的,我们将其称为职位:

For a website having users. Each user having the ability to create any amount of, we'll call it "posts":

效率更高 - 是更好地为所有帖子,为每个帖子保存创建帖子的用户的用户ID,或者为每个用户创建不同的单独,并只放置该用户创建的帖子。

Efficiency-wise - is it better to create one table for all of the posts, saving the user-id of the user which created the post, for each post - OR creating a different separate table for each user and putting there just the posts created by that user?

推荐答案

当您向其中添加更多数据时,数据库布局不应更改,因此用户数据肯定在一个表中。

The database layout should not change when you add more data to it, so the user data should definitely be in one table.

还有:


  • 拥有多个表意味着您必须动态创建查询。

  • Having multiple tables means that you have to create queries dynamically.

一个表的缓存查询计划不会用于任何其他表。

The cached query plan for one table won't be used for any other of the tables.

在一个表中有很多数据不会对性能产生太大的影响,但是有很多表。

Having a lot of data in one table doesn't affect performance much, but having a lot of tables does.

这篇关于数据库效率 - 每个用户的表与用户的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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