<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>llamerada</author_name>
  <author_url>https://blog.hatena.ne.jp/llamerada/</author_url>
  <blog_title>llameradaの日記</blog_title>
  <blog_url>https://llamerada.hatenadiary.org/</blog_url>
  <categories>
  </categories>
  <description>東京都で賢い借金返済方法を教えます！では、MySQLに格納したWikipedia記事をランダムに表示している。速度を気にしないなら、 SELECT * FROM docs ORDER BY RAND() LIMIT 10; で良いのだけど、レコード数が多いと遅くて使いものにならない。そこで、記事IDを1から始まる連番になるようにDBに格納している。このようにすると、アプリケーション側でDBに格納されている文書IDが全て分かるので、ランダムに文書IDを10個選択して、その文書IDのレコードを表示することで、ランダム表示を実現している。例えば、IDは10個選択するRubyコードは、 ids = A…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fllamerada.hatenadiary.org%2Fentry%2F20080413%2F1208073687&quot; title=&quot;MySQLでの高速な重み付きランダム表示 - llameradaの日記&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>2008-04-13 17:01:27</published>
  <title>MySQLでの高速な重み付きランダム表示</title>
  <type>rich</type>
  <url>https://llamerada.hatenadiary.org/entry/20080413/1208073687</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
