title: show efficiently database milion record
body: <p>I have a database with 10 millions of records. The table is structured as:</p>
  <p>Table name : record</p>
  <ul>
  <li>Filed1: Name (varchar)(Primary key)</li>
  <li>Field2: Record(int/bigint)(Index)</li>
  </ul>
  <p>example:</p>
  <pre><code>Name | Record
  Darrin | 256
  Aaron | 3
  Daryl | 12
  ...
  </code></pre>
  <p><strong>I want to create an html page that shows the ranking order by records like:</strong></p>
  <p>-https://stackexchange.com/leagues/1/week/stackoverflow/2016-10-30?sort=reputationchange&amp;page=1</p>
  <p>,but I have 2 problems:</p>
  <ul>
  <li><p><strong>the records are too many</strong> (ORDER BY take 20 second to order table without LIMIT)</p>
  </li>
  <li><p><strong>if I showed you a little at a time</strong> (eg first page 0-100, second page 100-200 ...)
  <strong>every page should invoke a query to sort the database like  :</strong><br />
  first page:  &quot;SELECT Name,Record FROM record ORDER BY Record DESC LIMIT 0,100&quot; second page:  &quot;SELECT Name,Record FROM record ORDER BY Record DESC LIMIT
  100,100&quot;</p>
  </li>
  </ul>
  <p><strong>This is very inefficient,and the time will increase a lot for the last query es :</strong></p>
  <p>-first page:  &quot;SELECT Name,Record FROM record ORDER BY Record DESC LIMIT 0,100&quot;<strong>--&gt;take 0.003 second</strong></p>
  <p>-last page:&quot;SELECT Name,Record FROM record ORDER BY Record DESC LIMIT 10.000.000,100&quot; <strong>--&gt;take 10 second</strong></p>
  <p>it is best to keep the database ordered while I INSERT Record?</p>
  <p>how can I do otherwise?</p>
  <p>how does the StackOverflow page mentioned above to load so quickly?</p>
  <p>Thank you!.</p>