Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I usually use query similar to this one (in PHP/MySQL), it's much faster than traditional offset query. You can compare it for yourself using EXPLAIN. Sure not for 100M records, but for 1M or so :)

  $items = db("SELECT a,b,c FROM item
           JOIN (SELECT id
              FROM item
              WHERE
              <your-where-conditions>
              ORDER BY id DESC
              LIMIT <offset>, <limit>)
              AS x ON
              x.id = item.id");


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: