All queries in this recipe should be performed by the bench_user mapped user in the pgbench database on the pg-report PostgreSQL server. Follow these steps:
- Execute the following simple query to view a remote query plan:
EXPLAIN VERBOSE SELECT aid, bid, abalance FROM pgbench_accounts WHERE aid BETWEEN 500000 AND 500004;
- Execute this SQL statement to examine how PostgreSQL handles remote aggregates:
EXPLAIN VERBOSE SELECT sum(abalance) FROM pgbench_accounts WHERE aid BETWEEN 500000 AND 500004;
- Execute this SQL statement to see a query plan involving a JOIN:
EXPLAIN VERBOSE SELECT a2.aid, a2.bid, a2.abalance FROM pgbench_accounts a1 JOIN pgbench_accounts a2 USING (aid) WHERE a1.aid BETWEEN 500000 AND 500004; ...