duanqiao1926 2016-08-05 05:44
浏览 9
已采纳

剂量ajax实时搜索效果SQL数据库? [关闭]

Im just wondering will SQL database be damaged, if you make a lot of queries for example using ajax live search, as when you add or delete a letter it will make a new query

thank you for you time :)

  • 写回答

1条回答 默认 最新

  • dongpeihui1051 2016-08-05 05:52
    关注

    Your database will not be damaged. Your website may become slow and laggy, not because of DB queries, but because of the many http requests while the user types. To make an effective live search there are a few things you can do:

    1. At the front end, only make requests to your PHP/Mysql once you have enough characters that you can get significant results. For example, only run the search after 4 characters are typed.
    2. Use rate-limiting at the front-end. This means wait for inactivity before you make another http request. Instead of making 4 requests a second if your user types 4 characters, wait until the user pauses for a bit (eg: 750 milliseconds) before you fire off a request.
    3. In Mysql, design your table to include a FULLTEXT index on the columns you wish to search frequently
    4. Design your queries to be as targeted as possible. For instance if you're running a search for job openings, you could have the user first select the industry and region she is interested in. That way you can add WHERE industry='...' AND region='...' to your query and it will run much faster. Anything that will allow you to focus the query.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 怎么获取下面的: glove_word2id.json和 glove_numpy.npy 这两个文件
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug