doufangzhang4454 2018-11-20 15:16
浏览 80

为过滤器大型阵列选择正确的模式 - Rest vs Local Array

Wich is the best approach for an app that aims to filter data, like 5000+ records, by keeping the response speed in focus?

A) Filter local memory arrays B) Query to db trought http api request calls

For my app i use angularjs, php and SQLite3. Right now i load all record from slite db to my table and then filter this field by search. All work great, but when I exceed 3000 records I notice a certain slowing down. By limiting the search on two fields, I get better performance. My doubt is if changing the model and querying the db I get a better performance or not.

A) Local array advantages - i can use JavaScript Array map() Method - low consuming data bandwidht - i can see all records in table before filter - i can work, after loading data, in offline.

A) Local array disadvantages - slowing down performance over 2000 record.

So can you help me to evaluate advantages and disavantages if i make http api call for any filter action request keeping in focus the performances?

Thank You

  • 写回答

1条回答 默认 最新

  • dsriya5471 2018-11-20 17:09
    关注

    I can't tell about caching in PHP, but for the AngularJS end, there's an approach you can follow:

    1. When the user searches for the first time, fetch the result(s) from db.
    2. Make 2 copies of the data: one presented to the user directly, another can be stores in a local json with a key value pair approach. 3.Next time the user searches for anything, look into the local json first for the result. If the data is present locally, no need for the db query, else make the db query and repeat step 2.

    The idea is not to make user wait for every search, you cannot simply call all 5000+ records at once and store locally, and you definitely cannot make db queries every-time since RDMS having that much records simply have low performance issues. So this seems best to me.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!