4 # You can import these to http://tatiyants.com/pev/#/plans/new
8 PSQL_CMD="docker exec -i dev_postgres_1 psql -qAt -U lemmy"
10 echo "explain (analyze, format json) select * from user_ limit 100" > explain.sql
11 cat explain.sql | $PSQL_CMD > user_.json
13 echo "explain (analyze, format json) select * from post p limit 100" > explain.sql
14 cat explain.sql | $PSQL_CMD > post.json
16 echo "explain (analyze, format json) select * from post p, post_aggregates pa where p.id = pa.post_id order by hot_rank(pa.score, pa.published) desc, pa.published desc limit 100" > explain.sql
17 cat explain.sql | $PSQL_CMD > post_ordered_by_rank.json
19 echo "explain (analyze, format json) select * from post p, post_aggregates pa where p.id = pa.post_id order by p.stickied desc, hot_rank(pa.score, pa.published) desc, pa.published desc limit 100" > explain.sql
20 cat explain.sql | $PSQL_CMD > post_ordered_by_stickied.json
22 echo "explain (analyze, format json) select * from comment limit 100" > explain.sql
23 cat explain.sql | $PSQL_CMD > comment.json
25 echo "explain (analyze, format json) select * from community limit 100" > explain.sql
26 cat explain.sql | $PSQL_CMD > community.json
28 echo "explain (analyze, format json) select * from community c, community_aggregates ca where c.id = ca.community_id order by hot_rank(ca.subscribers, ca.published) desc, ca.published desc limit 100" > explain.sql
29 cat explain.sql | $PSQL_CMD > community_ordered_by_subscribers.json
31 echo "explain (analyze, format json) select * from site s" > explain.sql
32 cat explain.sql | $PSQL_CMD > site.json
34 echo "explain (analyze, format json) select * from user_mention limit 100" > explain.sql
35 cat explain.sql | $PSQL_CMD > user_mention.json
37 echo "explain (analyze, format json) select * from private_message limit 100" > explain.sql
38 cat explain.sql | $PSQL_CMD > private_message.json
40 grep "Execution Time" *.json > ../timings-`date +%Y-%m-%d_%H-%M-%S`.out