Ruby on Rails 中的存储过程

我是一个拥有 6 年经验的 .net 人.最近我开始研究 ROR 项目并意识到根本没有使用存储过程/sql 函数.在询问它时,我知道这是一种常见的做法,通常团队中根本没有人编写 sql 查询,一切都是使用 ActiveRecord 完成的.

I am a .net guy with 6 years of experience. Recently I started working on ROR project and realized that stored procedures/sql functions are not being used at all. On inquiring about it I got to know that it is common practice and in general nobody in team writes a sql queries at all, everything is done using ActiveRecord.

我在谷歌上搜索了任何可能的原因,但没有找到太多信息.所以我只是想知道

I googled about any possible reasons for this but didn't find much information. So I am just curios to know

  1. 不喜欢使用存储过程/sql 函数是一种常见的做法吗?
  2. 使用存储过程的优缺点是什么?

推荐答案

不喜欢使用存储过程/sql 函数是一种常见的做法吗?

Is it common practice that stored procedures/sql functions are not preferred to use?

非常很常见,大多数 Rails 应用将永远不需要使用 ActiveRecord 以外的任何东西.

It is very common, most Rails apps will never need to use anything more than ActiveRecord.

Rails 背后的主要理念之一是,将有效产品推向市场今天比将快速"产品推向市场更重要 6几个月后.您的产品几乎肯定不会流行到足以让性能成为问题的程度.如果这确实成为一个问题,您可以稍后在性能方面提供支持,但当务之急是能够快速构建应用程序,并能够快速重构部分或全部以响应您的市场.

One of the chief philosophies behind Rails is that it's more important to get a working product to market today than it is to get a "fast" product to market 6 months from now. Your product will almost certainly never be popular enough for performance to be a concern. If that does become a problem, you can shore up the performance side of things later, but the immediate concern is to be able to build an app quickly, and to be able to rapidly refactor some or all of it in response to your market.

使用存储过程的优缺点是什么?

What are pros and cons of using stored procedures?

它们的编写速度较慢且更难更改,因此会增加您的开发成本.但是,它们的执行速度可以更快.

They're slower to write and more difficult to change, and therefore front-load your development costs. However, they can be faster to execute.

相关文章