4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

find_eachとeachの違い

Last updated at Posted at 2015-11-08

違い

Active Record クエリインターフェイス | Rails ガイド

DB操作で行いたいことのよくあることの1つ。

eachSQL的にLIMITをつけずに全件メモリに確保。
find_eachSQL的にLIMITをつけてデフォルトでは1000件ずつメモリに確保。

結局、Railsのlimitoffsetを自前で使えば、find_eachと似たようなことはできるのではないだろうか。

とはいえ

ただ表示するためのデータならば、
find_eachという選択よりもSQL的SELECTで取り出すデータ絞るって選択もありそう...

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?