显示大量mysql记录
如果我有一个包含 7000 条记录的 mysql 数据库,我必须在我的网页上显示所有 7000 条记录。是否有任何提示和技巧可以加快该过程(浏览器在显示所有记录之前几乎崩溃)我知道我应该查询它以减少所选记录的数量,但我实际上需要显示 7000...
If i had a mysql db with 7000 records in it and i had to display all 7000 on my webpage. Are there any tips and tricks to speed the process up (the browser practically crashes before showing all the records) i know i should query it to reduce the number of records selected but i actually need to display 7000...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
打开输出缓冲:http://php.net/manual/en/function。 ob-start.php
编辑
以下 php 获取 10K 产品并将其输出为表格,在 0.014 秒内没有任何问题。
SQL 脚本
也可以很好地处理 50K 记录,除了运行时潜水 - 页面在 0.112902 秒内生成
EDIT2
http://phplens.com/lens/php-book/optimizing-debugging-php.php
上述链接的摘录:
Turn on output buffering : http://php.net/manual/en/function.ob-start.php
EDIT
The following php fetches 10K products and outputs them as a table with no problems in 0.014 seconds.
SQL Script
Works fine with 50K records too except runtime dives - Page generated in 0.112902 secs
EDIT2
http://phplens.com/lens/php-book/optimizing-debugging-php.php
An excerpt from the above link:
我假设您在 PHP 中执行此操作(我不熟悉),但这对所有语言都是通用的。
首先将7000条记录查询到一个列表中,然后在脚本页面(例如php、jsp for java等)中显示所有列表。不允许您的 php 页面打开连接,读取列表中的每个项目并显示它们。客户端(浏览器)可能会无限期等待并导致会话超时
I'm assuming you're doing this in PHP (which I'm not familiar with) but this is generic to all languages.
Query 7000 records into a list first, then display all the list in a scripting page (e.g. php, jsp for java, etc.). Don't allow your php page to open the connection, read each item from the list and displaying them. The client (browser) might wait indefinitely and cause a session timeout
f00:如果他将结果显示在表格中,浏览器将继续显示数据,但无论如何都不会正确显示。据我所知,该表无法正确渲染(在 Firefox 中)...
我认为对表进行分页是唯一可能的解决方案......
f00: if he displays the result in table and the browser will survive to display the data, they wont be displayed correcly anyways. As far as I know, the table wont render correctly (in firefox)...
I think that paging the table is the only possible solution...