高效的服务器端自动完成 [英] efficient serverside autocomplete

查看:104
本文介绍了高效的服务器端自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先我所知道的:

premature优化是一切罪恶的根源。

Premature optimization is the root of all evil

但我想错了自动完成真能炸掉你的网站。

But I think wrong autocomplete can really blow up your site.

我将向知道,如果有,能有效(服务器端)做任何自动完成出库,其中有preferable可以放入RAM(以实现最佳性能)。因此,没有browserside的JavaScript自动完成(YUI / jQuery的/道场)。我觉得有这个计算器上足够的话题。但我找不到这个计算器上的一个很好的线程(也许没有看够好)。

I would to know if there are any libraries out there which can do autocomplete efficiently(serverside) which preferable can fit into RAM(for best performance). So no browserside javascript autocomplete(yui/jquery/dojo). I think there are enough topic about this on stackoverflow. But I could not find a good thread about this on stackoverflow (maybe did not look good enough).

例如自动完成名称:

names:[alfred, miathe, .., ..]

我能想到:


  • 简单的SQL就像例如: SELECT名用户的WHERE名称LIKE人%

    • 我觉得这个实现将炸毁了很多同时用户或大型数据集,但也许我错了,所以数字(这可能是处理)将是很酷。


    • 我不知道这样的表现与大网站,这样用户请告诉我。

    我想听到的是由它能够多有效处理负载preferable与网站和数字使用的实现:

    What I would like to hear is implementation used by sites and numbers of how well it can handle load preferable with:


    • 链接到实现或code。

    • 号码,你知道它可以扩展。

    • 这将是很好,如果它可以通过HTTP或插槽。被accesed

    非常感谢,结果
    阿尔弗雷德

    Many thanks,
    Alfred

    推荐答案

    不幸的是,这个问题的解决将在很大程度上取决于你希望查询数据。

    Optimising for Auto-complete

    Unfortunately, the resolution of this issue will depend heavily on the data you are hoping to query.

    之类的查询会不会把你的数据库太大的压力,只要你使用解释或探查向您展示查询优化计划如何执行查询花时间。

    LIKE queries will not put too much strain on your database, as long as you spend time using 'EXPLAIN' or the profiler to show you how the query optimiser plans to perform your query.

    一些基础知识要牢记:


    • 指标:确保你有指标的设置。 (是的,在很多情况下,像确实使用了索引。有上myitforum该主题的优秀文章。的 SQL性能 - 索引和LIKE子句

    连接:确保您的连接是到位,被查询规划进行了优化。 SQL Server设置可以帮助这一点。查找出完整的索引,或全表扫描

    Joins: Ensure your JOINs are in place and are optimized by the query planner. SQL Server Profiler can help with this. Look out for full index or full table scans

    自动完成查询是一个特殊的情况下,他们通常工作的不断降低子集。

    Auto-complete queries are a special case, in that they usually works as ever decreasing sub sets.


    • 名称LIKE'%一个(可能会返回10000条记录)

    • 名称LIKE'%人(可能会返回500条记录)

    • '名称'LIKE'阿拉%(可能会返回75条记录)

    • 名称LIKE'%艾伦(可能会返回20条记录)

    • 'name' LIKE 'a%' (may return 10000 records)
    • 'name' LIKE 'al%' (may return 500 records)
    • 'name' LIKE 'ala%' (may return 75 records)
    • 'name' LIKE 'alan%' (may return 20 records)

    如果您返回整个结果查询1,那么就没有必要再次命中数据库以下结果集,因为他们是一个子集的原始查询。

    If you return the entire resultset for query 1 then there is no need to hit the database again for the following result sets as they are a sub set of your original query.

    根据您的数据,这可能会打开优化进一步的机会。

    Depending on your data, this may open a further opportunity for optimisation.

    这篇关于高效的服务器端自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆