| 1 | -- One profile, planned the way our servers plan it: make explain Q=profile U=1 |
| 2 | set plan_cache_mode = force_generic_plan; |
| 3 | prepare profile(text, bigint) as |
| 4 | select u.handle, u.created_at, u.followers_count, |
| 5 | (select count(*) from follows where follower_id = u.id), |
| 6 | (select count(*) from posts where user_id = u.id), |
| 7 | exists (select 1 from follows where follower_id = $2 and followee_id = u.id) |
| 8 | from users u |
| 9 | where u.handle = $1; |
| 10 | explain (analyze, costs off, timing off) execute profile('user' || :user, 42); |