简体   繁体   English

加快搜索结果显示的最佳方法

[英]Best way to speed up search result display

We've been prototyping a search results system for a mySQL database with about 2 million names and addresses and 3 million associated subscription and conference attendance records. 我们一直在为mySQL数据库建立搜索结果系统原型,其中包含大约200万个名称和地址以及300万个相关的订阅和会议出勤记录。

At the moment the search is executed and all results returned - for each result I then execute a second query to look up subscriptions / conferences for the person's unique ID. 在执行搜索并返回所有结果的那一刻 - 对于每个结果,我然后执行第二个查询以查找该人的唯一ID的订阅/会议。 I've got indexes on all the important columns and the individual queries execute quite quickly in phpMyAdmin (0.0xxx seconds) but feed this into a webpage to display (PHP, paged using DataTables) and the page takes seconds to render. 我在所有重要的列上都有索引,并且各个查询在phpMyAdmin(0.0xxx秒)内执行得非常快,但是将其提供给要显示的网页(PHP,使用DataTables分页),页面需要几秒钟才能呈现。 We've tried porting the data to a Lucene database and it's like LIGHTNING but the bottleneck still seems to be displayng the results rather than retrieving them. 我们已经尝试将数据移植到Lucene数据库,它就像LIGHTNING,但瓶颈似乎仍然显示结果而不是检索它们。

I guess this would be due to the overhead of building, serving and rendering the page in browser. 我想这可能是由于在浏览器中构建,提供和呈现页面的开销。 I think I can remove the subquery I mention above by doing GROUP_CONCAT to get the subscription codes in the original query, but how can I speed up the display of the page with the results on? 我想我可以删除上面提到的子查询,通过执行GROUP_CONCAT来获取原始查询中的订阅代码,但是如何加快显示结果的页面?

I'm thinking little and often querying with AJAX / server side paging might be the way to go here (maybe get 50 results, the query is smaller, the page is smaller and can be served quicker) but I welcome any suggestions you guys might have. 我想的很少,经常使用AJAX /服务器端分页查询可能是这里的方式(可能得到50个结果,查询更小,页面更小,可以更快地提供)但我欢迎任何建议你们可能有。

Even if you are using pagination with Datatables, all the results are loaded into the page source code at first although you are using the server side feature. 即使您使用Datatables分页,所有结果也会首先加载到页面源代码中,尽管您使用的是服务器端功能。

Loading 2 million rows at once will always render slowly. 一次加载200万行总是缓慢渲染。 You have to go for server side pagination, it can be by AJAX or by a normal PHP script. 您必须使用服务器端分页,它可以通过AJAX或普通的PHP脚本。

You can also consider using a cache system to speed up the loading of data from the server and avoiding calling the database when it is not needed. 您还可以考虑使用缓存系统来加速从服务器加载数据,并避免在不需要时调用数据库。 If your data can be changing randomly in time, you can always use a function to check whether or not the data has changed since the last time you cached the data and if so, updating the cached data. 如果您的数据可以随时随机更改,您始终可以使用函数来检查自上次缓存数据后数据是否已更改,如果是,则更新缓存的数据。

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

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