| 1 | -- The feed query, for one user: make explain U=42 |
| 2 | explain (analyze, costs off, timing off) |
| 3 | select p.id, u.handle, p.body, p.created_at |
| 4 | from follows f |
| 5 | cross join lateral ( |
| 6 | select id, user_id, body, created_at |
| 7 | from posts |
| 8 | where user_id = f.followee_id and id < 9223372036854775807 |
| 9 | order by id desc |
| 10 | limit 21 |
| 11 | ) p |
| 12 | join users u on u.id = p.user_id |
| 13 | where f.follower_id = :user |
| 14 | order by p.id desc |
| 15 | limit 21; |