w0bm / w0bm-rs

new experimental w0bm backend
MIT License
3 stars 0 forks source link

Infinite Scrolling #2

Open belst opened 6 years ago

belst commented 6 years ago

Queries my dude:

Initial:

SELECT * FROM videos
ORDER BY created_at DESC, id DESC -- latest on top
LIMIT 50; -- 50 = pagesize

later: query with ?after_date=<latest_created_at>&after_id=<latest_id>

SELECT * FROM videos
WHERE (created_at, id) < (<latest_created_at>, <latest_id>)
ORDER BY created_at DESC, id DESC
LIMIT 50;

Disadvantages: cannot jump to specific page. Advantages: very fast and perfect for infinite scrolling

belst commented 6 years ago

standard pagination: https://github.com/diesel-rs/diesel/blob/v1.3.0/examples/postgres/advanced-blog-cli/src/pagination.rs