<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>yanterakun</author_name>
  <author_url>https://blog.hatena.ne.jp/yanterakun/</author_url>
  <blog_title>下級エンジニアの綴</blog_title>
  <blog_url>https://yanterakun.hatenablog.com/</blog_url>
  <categories>
    <anon>ruby</anon>
  </categories>
  <description>countを使わなくて失敗したので戒めを含めメモ。 Active Recordのデータ(配列)に対して sizeを使えば配列を全てオンメモリで扱って、結果を返す。 countはを使えばdbに投げて結果を返してくれる。 ↑のことはわかっていたけど、物理的な部分を理解しているつもりで終わっていた。 例えば、100件程度のデータならsizeの方が良いと思うが、数十万件となるとcountの方が良いと思う。 理由としては 数十万件のデータを全てメモリに載せようとするとおそらくメモリが足りずに落ちる からである。 blank?とかpresent?とかも同じことが言える。 配列を判定する時に値が存在する、存…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fyanterakun.hatenablog.com%2Fentry%2F2018%2F02%2F13%2F070000&quot; title=&quot;rubyのcountについてメモ - 下級エンジニアの綴&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2018-02-13 07:00:00</published>
  <title>rubyのcountについてメモ</title>
  <type>rich</type>
  <url>https://yanterakun.hatenablog.com/entry/2018/02/13/070000</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
