为每个用户创建表? [英] Creating table for each user?

查看:146
本文介绍了为每个用户创建表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Web应用程序,其中每个用户存储他们的任务。 (像一个待办事项)。任务将存储在表中(例如: userstasks )。

I'm programming a web application in which each user stores their tasks. (like a to-do application). Tasks will be stored in a table (for example: userstasks).

哪一个更好?

1- userstasks 表有一个名为user_id的列,用于定义谁创建任务?

1- userstasks table has a column named user_id that defines who created task?

PS:有很多用户!

推荐答案

始终从最简单的事情开始,坚持下去,直到成为一个性能问题。你正在谈论的#2被称为过早优化。只有在#1遇到严重的性能问题时,您才能走上这条路。

You always start with the simplest thing that works and stick with it until it's proven to be a performance problem. What you're talking about with #2 is termed "premature optimization". You only go down that road when #1 is having severe performance problems.

当您跨不同用户分割数据时,您在所有用户之间查询的能力会大大降低。对于所有意图,用户将生活在不同的世界。报告几乎是不可能的。

When you split data across different users, your ability to query across all users is severely diminished. For all intents, users will be living in different worlds. Reporting is nearly impossible.

对于大多数有大量读取的应用程序,数百万条记录不是问题。它是书写重的应用程序,需要特别注意像这样,或大规模,如Reddit或Twitter的。由于您不是在制作其中的一个,请先使用正常规范的结构。

For most applications that have a lot of reads, millions of records is not an issue. It's write-heavy applications that need special attention like this, or those with massive scale, like Reddit or Twitter. Since you're not making one of those, stick with the properly normalized structure first.

很多用户可能意味着几十或几十万。在一个正确调整的MySQL实例,这不是一个大事。如果你需要更多的规模,启动一些只读的辅助服务器,以分散负载或查看使用MySQL集群。

"Lots of users" probably means tens or hundreds of thousands. On a properly tuned MySQL instance that's not a big deal. If you need more scale, spin up some read-only secondary servers to spread out the load or look at using MySQL cluster.

这篇关于为每个用户创建表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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