简体   繁体   English

Ruby on Rails:实现查询大量数据的最佳方法

[英]Ruby on Rails: Best way to implement querying big amount of data

I'm creating an application that is very heavy in data, almost like an inventory system. 我正在创建一个数据量非常大的应用程序,就像库存系统一样。 In index, I had to query/load a big amount of data, and inside my controller, I have this code. 在索引中,我不得不查询/加载大量数据,并且在我的控制器内部,我有这段代码。

@vehicles = Vehicle.all

@vehicles will all be listed in the corresponding view. @vehicles将全部列在相应的视图中。

At first, this was not a problem because the number of vehicles was just around hundreds. 最初,这不是问题,因为车辆数量仅为数百辆。 But as the vehicle's number increases, the application becomes very slow. 但是随着车辆数量的增加,应用变得非常缓慢。

What is the best way to implement this kind of scenario in RoR? 在RoR中实施这种方案的最佳方法是什么?

Have you considered pagination? 您是否考虑过分页? Because even if the DB is fast and instandly returns your data, the view/html will be so long, that rendering will take very long 因为即使数据库快速且可以理解地返回您的数据,视图/ html也会很长,因此渲染将花费很长时间

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

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