CREATE TABLE sales ( id INT PRIMRY KEY, log_time TIMESTAMP NOT NULL, message CHAR(40) NOT NULL );
DETAIL: CPU 0.00s/0.00u sec elapsed 0.00 sec. INFO: "tbl": found 4 removable, 1 nonremovable row versions in 1 pages DETAIL: 0 dead row versions cannot be removed yet. There were 0 unused item pointers. 0 pages are entirely empty. CPU 0.00s/0.00u sec elapsed 0.00 sec. INFO: "toast_item": truncated 1 to 0 pages
=# SELECT * FROM pg_locks ; relation | database | transaction | pid | mode | granted ----------+----------+-------------+------+-----------------+--------- 177381 | 177205 | | 3738 | AccessShareLock | t 177381 | 177205 | | 3738 | RowShareLock | t | | 1226 | 3738 | ExclusiveLock | t 16759 | 177205 | | 3736 | AccessShareLock | t | | 1228 | 3736 | ExclusiveLock | t (5 rows)
QUERY PLAN ------------------------------------------------------------------- HashAggregate (cost=410.07..410.07 rows=1000 width=19) ...(1) -> Hash Join (cost=19.50..359.83 rows=10049 width=19) ...(2) Hash Cond: ("outer".iid = "inner".id) -> Seq Scan on sales s (cost=0.00..164.48 rows=10048 width=4) ...(3) -> Hash (cost=17.00..17.00 rows=1000 width=23) -> Seq Scan on item i (cost=0.00..17.00 rows=1000 width=23) ...(4) (6 rows)
=> EXPLAIN SELECT i.name FROM sales s -> JOIN item i ON i.id = s.item_id WHERE s.number > 10; QUERY PLAN ------------------------------------------------------------------- Hash Join (cost=2.27..3.74 rows=6 width=31) Hash Cond: ("outer".id = "inner".item_id) -> Seq Scan on item i (cost=0.00..1.15 rows=15 width=35) -> Hash (cost=2.25..2.25 rows=6 width=4) -> Seq Scan on sales s (cost=0.00..2.25 rows=6 width=4) Filter: (number > 10) (6 rows)