使用 PHP 应用程序输入的数据管理多个 MySQL 1 GB 数据库

发布于 2024-12-20 02:49:06 字数 627 浏览 0 评论 0原文

我正在创建一个利用 MySQL 和 PHP 的应用程序。我当前的网络托管提供商的 MySQL 数据库大小限制为 1 GB,但我可以创建许多 1 GB 数据库。即使能够找到另一个允许更大数据库的网络托管提供商,我想知道更大数据库如何影响数据完整性和速度?就磁盘大小而言,保持数据库较小是否更好?换句话说,存储来自数千个用户的相同数据(所有文本)的最佳实践方法是什么?我是数据库设计和规划的新手。最终,我会想象,包含来自数千个用户的数据的单个数据库将变得效率低下,并且最佳情况下,数据应该分布在较小的数据库中。我这个正确吗?

在相关说明中,我的应用程序如何知道何时创建另一个表(或切换到手动创建的另一个表)?例如,如果我有 1 个数据库,其中包含 1 GB 的数据,我希望我的应用程序能够继续工作而不会出现任何服务延迟。如何控制从一个表到第二个新创建的数据库的数据输入?

同样,如果一个用户在 2011 年加入该网站并创建了 100 条信息记录,并且数千个其他用户也做了同样的事情,那么 1 GB 的数据库就会被填满。随后,该原始用户添加了在另一个 1 GB 数据库中创建的额外 100 条记录。我的 PHP 代码如何知道要在哪个数据库中查询 2 组 100 条记录?这会在 MySQL 端以某种方式自动管理吗?是否需要在 PHP 代码中管理 IF/THEN/ELSE 语句?这是某些网络托管提供商提供的服务吗?

I am creating an application that utilizes MySQL and PHP. My current web hosting provider has a MySQL database size limitation of 1 GB, but I am allowed to create many 1 GB databases. Even if was able to find another web hosting provider that allowed larger databases, I wonder how is data integrity and speed affected by larger databases? Is it better to keep databases small in terms of disk size? In other words, what is the best practice method of storing the same data (all text) from thousands of users? I am new to database design and planning. Eventually, I would imagine that a single database with data from thousands of users would grow to be inefficient and optimally the data should be distributed among smaller databases. Do I have this correct?

On a related note, how would my application know when to create another table (or switch to another table that was manually created)? For example, if I had 1 database that filled up with 1 GB of data, I would want my application to continue working without any service delays. How would I control the input of data from 1 table to a second, newly created database?

Similarly, if a user joins the website in 2011 and creates 100 records of information, and thousands of other users do the same, and then the 1 GB database becomes filled. Later on, that original user adds an additional 100 records that are created in another 1 GB database. How would my PHP code know which database to query for the 2 sets of 100 records? Would this be managed automatically in some way on the MySQL end? Would it need to be managed in the PHP code would IF/THEN/ELSE statements? Is this a service that some web hosting providers offer?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

西瑶 2024-12-27 02:49:06

这是一个非常抽象的问题,我不确定通用的 stackoverflow 是否是正确的地方。

无论如何。存储的最佳实践方法是什么?怎么样:在磁盘上的文件中。请记住,数据库只是一个美化的文件,具有奇特的“读”和“写”命令。

优化是很困难的,你只能进行交易。 CPU 用于内存使用情况、读取速度用于写入速度、批量数据存储或速度。 (或者找一个更好的主机提供商,让你的数据库尽可能大;))

要回答你的第二个问题,如果你确实采用你的数据库方法,你将需要设置一些系统来将用户从数据库“迁移”到如果一个人吃饱了,另一个。如果达到 1GB 的 80%,则开始迁移用户。

检测数据库的大小是一个棘手的问题。我想你可以查看磁盘上的 RAW 文件来看看它们有多大,但也许还有更聪明的方法。

This is a very abstract question and I'm not sure the generic stackoverflow is the right place to do it.

In any case. What is the best practice method of storing? How about: in a file on disk. Keep in mind that a database is just a glorified file that has fancy 'read' and 'write' commands.

Optimization is hard, you can only ever trade things. CPU for memory usage, read speed for write speed, bulk data storage or speed. (Or get a better host provider and make your databases as large as you want ;) )

To answer your second question, if you do go with your database approach you will need to set up some system to 'migrate' users from a database to another if one gets full. If you reach 80% of 1GB, start migrating users.

Detecting the size of a database is a tricky problem. You could, I suppose look at the RAW files on disk to see how big they are, but perhaps there are more clever ways.

对不⑦ 2024-12-27 02:49:06

我建议使用 SQLite 将是您的情况的最佳选择。它支持 2 TB(2^41 字节)数据库,最好的部分是它不需要服务器端安装。所以它在任何地方都是兼容的。您所需要的只是一个使用 SQLite 数据库的库。

您还可以选择主机,而无需查看它们支持哪些数据库和大小。

I would suggest using SQLite will the best option in your case. It supports 2 terabytes (2^41 bytes) database and best part is that it requires no server side installation. So it is compatible everywhere. All you need is a library to work with SQLite database.

You can also choose your host without looking on what databases and sizes do they support.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文