3 EXPLAIN="EXPLAIN(ANALYZE,COSTS)"
5 echo "ex1.5.a unoptimized"
6 echo "${EXPLAIN} SELECT distinct(displayname) FROM users u WHERE id IN (SELECT owneruserid FROM posts p WHERE p.viewcount > u.views);" | psql
8 echo "ex1.5.a optimized"
9 echo "${EXPLAIN} SELECT distinct(displayname) FROM posts p JOIN users u ON u.id = p.owneruserid WHERE p.viewcount > u.views;" | psql