[英]Improve results of a “search” input field?
I have a database with 20,000 records. 我有一个包含20,000条记录的数据库。 Each record has a name.
每条记录都有一个名字。 When a user wants to view a record, he can visit a webapp and type the name of the record in an inputfield.
当用户想要查看记录时,他可以访问webapp并在输入字段中键入记录的名称。 While typing, results from the database would be shown/filtered matchin what the user typed.
在键入时,数据库的结果将显示/过滤用户键入的内容。 I would like to know the basic architecture/concepts on how to program this
我想知道如何编程的基本架构/概念
I'm using the following language stack: frontend: html5/javascript (+ajax to make instant calls while user is typing) backend: java + jdbc to connect to simple sql database 我正在使用以下语言堆栈:前端:html5 / javascript(+ ajax在用户输入时进行即时调用)后端:java + jdbc连接到简单的sql数据库
My initial idea is: 我最初的想法是:
My two concerns are: the high amount of ajax requests to process, in conjunction with the possibly very heavy LIKE queries. 我的两个问题是:需要处理大量的ajax请求,以及可能非常繁重的LIKE查询。 What are ways to optimize this?
有什么方法可以优化这个? Only search for every two characters they type/remove?
只搜索他们输入/删除的每两个字符? Only query for the first ten results?
只查询前十个结果?
Do you know of websites that utilise these optimizations? 您知道利用这些优化的网站吗?
NOTE: assume the records are persons and names are like real people names, so some names are more common than others. 注意:假设记录是人,名称就像真人名,所以有些名称比其他名称更常见。
您可以选择SPA方法 - 将所有20 000个名称/ ID加载到客户端,然后在内存中过滤 - 它应该是最快的方式,对数据库和后端的负载最小
Here are possible solutions: 以下是可能的解决方案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.