mysql 中可以创建的数据库的最大限制?
我可以在Mysql中创建多达500000000个数据库吗?
如果有的话,效率高吗??
在这里,每个数据库都保存用户数据,其中有 6 个表,其中包含用户信息。
请向我解释一下这个想法在性能和实现方面的优缺点。
can i create as many as 500000000 databases in Mysql??
If yes, is it efficient??
here, each database holds user data with 6 tables in it containing user info in it..
please explain me the pros and cons of this idea with respect to performance and implementation..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请不要!
无论你在想什么,无论出于什么原因。创建那么多数据库绝对不是一个好主意。
如果您正在寻找存储每个用户或每个 X 的数据,那么请再次查看什么是关系数据库“关系数据库通过使用数据集中发现的共同特征来匹配数据。”
假设您正在创建图像服务并希望每个用户都有自己的图像。一种方法是为每个用户提供自己的数据库。这是错误的,因为每个用户的数据都包含相同的特征,唯一不同的是关系(用户A有图片A,用户B有图片B),(1个用户有0...*张图片,并且1 张图片属于 1 个用户)。因此,您不必创建那么多数据库,而是创建一个用户表,并将其与图片表相关联,这样您就可以有效地使用数据库。
回答你更直接的问题。创建一个包含 50,000 个条目的表肯定比创建 50,000 个数据库更有效。
在 mysql.com 上编辑相关答案:http://forums。 mysql.com/read.php?20,74692,74705#msg-74705
Please Don't!
Whatever you're thinking, whatever the reason. There is absolutely no way that creating that many databases is a good idea.
If you're looking for storing data per user, or for every X. Then please take a look again at what a relational database is "A relational database matches data by using common characteristics found within the data set."
Let's say you're createing an image service and want each user to have their own images. One way is to give each user their own database. This is wrong, because the data for each user contains the same characteristics, the only thing that is different is the relation (user A has picture A, user B has picture B), (1 user has 0...* pictures, and 1 picture belongs to 1 user). So instead of creating that many databases, you create a user table, and relate that to a picture table, this way you've efficiently used a database.
To answer your more direct question. Create a table with 50.000 entries is surely more efficient then creating 50.000 databases.
Edit a related answer on mysql.com: http://forums.mysql.com/read.php?20,74692,74705#msg-74705
为每个唯一用户创建完整的数据库并不理想。您现在强制 SQL 存储每个数据库并独立引用每个表。更不用说,数据库现在必须更加努力地检索和存储这些在数据库之间传输的信息。
出于标准化目的,您最好在每个表中创建一个“用户”列,您可以调用该列来进行 CRUD 操作。这将所有内容都集中在一处,并减轻了数据库的压力。
Creating a complete database for each unique user is less than ideal. You're now forcing SQL to store each database and independently reference each table. Not to mention, the database has to now work harder at retrieving and storing this information as it's going between databases.
For normalization purposes, you're better off making a "user" column in each table that you can call upon for your CRUD operations. This keeps everything all in one place, and keeps the strain off of the database.
我怀疑他是出于性能原因而想知道这一点 - 不是因为他不知道更多。
随着数据库的增长,每个用户在唯一数据库中的查找不会变慢 - 因为,简单地说,它不会变慢。
然而,如果您愿意不遗余力地提高性能,我个人的观点是首先考虑不同的 DBMS。我对 mySQL 的个人经验是,如果速度不是问题的话,它是一个非常好的 DBMS - 我个人发现 MSSQL 快得多。
i suspect he is wondering this for performance reasons - not because he knows no better.
lookups in a unique db for each user will not get slower as the db grows - because, simply, it wont.
However, if you are willing to go to these lengths to improve performance, my personal opinion would be consider a different DBMS first. My personal experience with mySQL is that its a very good DBMS if speed is not a concern - I've personally found MSSQL much much faster.