QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=125493.83..125498.35 rows=1810 width=306) Sort Key: (((uw.name_last)::text || ', '::text) || (uw.name_first)::text), o.job_title -> Hash Join (cost=30904.77..125395.89 rows=1810 width=306) Hash Cond: ("outer".keyf_locationid = "inner".keyp_locationid) -> Hash Join (cost=30827.73..125263.35 rows=1929 width=292) Hash Cond: ("outer".keyf_invoiceid = "inner".keyp_invoiceid) -> Hash Join (cost=30362.29..123695.58 rows=2001 width=288) Hash Cond: ("outer".keyf_orderid = "inner".keyp_orderid) -> Seq Scan on timecard t (cost=0.00..92465.02 rows=42412 width=108) Filter: ((week_ending >= '2006-04-02'::date) AND (week_ending <= '2006-04-30'::date)) -> Hash (cost=30344.41..30344.41 rows=7154 width=184) -> Hash Join (cost=25801.65..30344.41 rows=7154 width=184) Hash Cond: ("outer".keyf_address_buildingid = "inner".keyp_address_buildingid) -> Hash Join (cost=25572.65..29853.27 rows=7624 width=155) Hash Cond: ("outer".keyf_supplierid = "inner".keyp_supplierid) -> Merge Right Join (cost=25091.38..29151.62 rows=8236 width=133) Merge Cond: ("outer".keyp_departmentid = "inner".keyf_parentid) -> Index Scan using department_pkey on department d2 (cost=0.00..3725.11 rows=84901 width=22) -> Sort (cost=25091.38..25111.97 rows=8236 width=119) Sort Key: d1.keyf_parentid -> Merge Right Join (cost=20494.95..24555.72 rows=8236 width=119) Merge Cond: ("outer".keyp_departmentid = "inner".keyf_departmentid) -> Index Scan using department_pkey on department d1 (cost=0.00..3725.11 rows=84901 width=36) -> Sort (cost=20494.95..20515.54 rows=8236 width=91) Sort Key: o.keyf_departmentid -> Merge Right Join (cost=16935.57..19959.30 rows=8236 width=91) Merge Cond: ("outer".keyf_managerid = "inner".keyf_managerid) -> Index Scan using users_managerid on users um (cost=0.00..9993.43 rows=126903 width=23) -> Sort (cost=16935.57..16956.16 rows=8236 width=76) Sort Key: o.keyf_managerid -> Merge Right Join (cost=11006.83..16399.91 rows=8236 width=76) Merge Cond: ("outer".keyf_workerid = "inner".keyf_workerid) -> Index Scan using users_workerid on users uw (cost=0.00..10067.22 rows=126903 width=23) -> Sort (cost=11006.83..11027.42 rows=8236 width=57) Sort Key: o.keyf_workerid -> Bitmap Heap Scan on orders o (cost=48.83..10471.17 rows=8236 width=57) Recheck Cond: (keyf_clientid = 8) -> Bitmap Index Scan on orders_clientid_idx (cost=0.00..48.83 rows=8236 width=0) Index Cond: (keyf_clientid = 8) -> Hash (cost=449.62..449.62 rows=12662 width=30) -> Seq Scan on supplier s (cost=0.00..449.62 rows=12662 width=30) -> Hash (cost=205.40..205.40 rows=9440 width=37) -> Seq Scan on address_building ab (cost=0.00..205.40 rows=9440 width=37) -> Hash (cost=420.55..420.55 rows=17955 width=8) -> Seq Scan on invoice i (cost=0.00..420.55 rows=17955 width=8) -> Hash (cost=68.03..68.03 rows=3603 width=22) -> Seq Scan on "location" l (cost=0.00..68.03 rows=3603 width=22) (47 rows)