<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>s_ochi</author_name>
  <author_url>https://blog.hatena.ne.jp/s_ochi/</author_url>
  <blog_title>ITANDI Engineer Blog</blog_title>
  <blog_url>https://tech.itandi.co.jp/</blog_url>
  <categories>
  </categories>
  <description>はじめに イタンジ株式会社の開発の越智です。現在、「物件管理くん」というサービスの開発を担当しています。 本記事ではRailsアプリケーションのN+1問題を解消する方法として挙げられる、ActiveRecordのメソッドについてまとめます。 N+1問題とは？ N+1問題とは、ループ処理の中で都度 SQL を発行してしまい、大量の SQL が発行されてパフォーマンスが低下してしまう問題のことです。 これだけだと抽象的すぎるので、具体例を示します。 以下のようなテーブルを考え、companiesテーブル：storesテーブル = １：多の関係とします。 今回使用するテーブルのER図 以下は、企業(…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Ftech.itandi.co.jp%2Fentry%2F2023%2F03%2F14%2F180000&quot; title=&quot;N+1問題を解決するActiveRecordのメソッドの使い分け - ITANDI Engineer Blog&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>https://cdn-ak.f.st-hatena.com/images/fotolife/t/t_sato3/20230313/20230313194107.png</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2023-03-14 18:00:00</published>
  <title>N+1問題を解決するActiveRecordのメソッドの使い分け</title>
  <type>rich</type>
  <url>https://tech.itandi.co.jp/entry/2023/03/14/180000</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
