简体   繁体   English

PHP和MySQL的最大报告

[英]Biggest reports with PHP and MySQL

Good afternoon. 下午好。

I think you're question is old already, but still have not got a definitive answer. 我认为您的问题已经很老了,但仍然没有确切的答案。 In a software that has millions (even billions) you need to make a report, but it is impossible to do so without seeking all the data and work with them in PHP, for example. 在拥有数百万(甚至数十亿)的软件中,您需要进行报告,但是,例如,如果不查找所有数据并在PHP中使用它们,就不可能这样做。

problems: 问题:

1 - Naturally these records will take a lot to get to PHP since the data size is counted in GB. 1-自然,这些记录需要花费很多时间才能到达PHP,因为数据大小以GB为单位。 2 - Put all that data into a PHP array to treat them will cause the memory is not enough. 2-将所有数据放入PHP数组以对其进行处理将导致内存不足。

Does anyone of you have gone through this dilemma? 你们中有人遇到过这种困境吗? For in tables with thousands of data'm already experiencing slowness, and the problem is not the query as it was atimizada for me (which I admit is not a great connoisseur of the database) and most experts, the problem really is in PHP . 因为在具有成千上万个数据的表中已经出现了速度慢的问题,但问题不在于查询,因为它对我(我承认不是数据库的鉴赏家)和我的大多数人一样,问题确实出在PHP中。 ITERATE've heard of, but maybe you know a solution with longer example. ITERATE听说过,但也许您知道带有更长示例的解决方案。

I believe this question to serve many users who have gone or are still going through it. 我相信这个问题可以为已经或正在经历的许多用户提供服务。

I thank you. 我谢谢你。

Usually when you have this much data you should load only a chunk of it in memory each time. 通常,当您拥有这么多的数据时,每次应该仅将其一部分加载到内存中。
Perform your operation on each chunk and calculate the final report. 对每个块执行操作并计算最终报告。

If your operation are simple enough you can let MySQL do it for you, provided you have a good amount of RAM (but that is cheap to buy). 如果您的操作足够简单,只要您有足够的RAM(但是价格便宜),就可以让MySQL为您完成。

Also note that if you have more data than the amount of your memory it doesn't not matter if you use PHP or any other language. 还要注意,如果您的数据多于内存量,则使用PHP或任何其他语言都没关系。 The algorithm you use is the main concern. 您使用的算法是主要问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM