QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=129334.05..129334.06 rows=1 width=305) Sort Key: (((uw.name_last)::text || ', '::text) || (uw.name_first)::text), o.job_title -> Nested Loop (cost=30150.77..129334.04 rows=1 width=305) -> Nested Loop (cost=30150.77..129329.51 rows=1 width=301) -> Nested Loop (cost=30150.77..129325.02 rows=1 width=280) -> Nested Loop (cost=30150.77..129320.54 rows=1 width=266) -> Nested Loop (cost=30150.77..129316.64 rows=1 width=237) Join Filter: ("outer".keyf_orderid = "inner".keyp_orderid) -> Seq Scan on timecard t (cost=0.00..95010.50 rows=1 width=108) Filter: ((week_ending >= '04/02/2006'::date) AND (week_ending <= '04/30/2006'::date)) -> Merge Right Join (cost=30150.77..34168.90 rows=10979 width=133) Merge Cond: ("outer".keyp_departmentid = "inner".keyf_parentid) -> Index Scan using department_pkey on department d2 (cost=0.00..3775.63 rows=84962 width=22) -> Sort (cost=30150.77..30178.22 rows=10979 width=119) Sort Key: d1.keyf_parentid -> Merge Right Join (cost=25261.41..29413.95 rows=10979 width=119) Merge Cond: ("outer".keyp_departmentid = "inner".keyf_departmentid) -> Index Scan using department_pkey on department d1 (cost=0.00..3775.63 rows=84962 width=36) -> Sort (cost=25261.41..25288.85 rows=10979 width=91) Sort Key: o.keyf_departmentid -> Merge Right Join (cost=21271.06..24524.58 rows=10979 width=91) Merge Cond: ("outer".keyf_managerid = "inner".keyf_managerid) -> Index Scan using users_managerid on users um (cost=0.00..10381.20 rows=141125 width=23) -> Sort (cost=21271.06..21298.50 rows=10979 width=76) Sort Key: o.keyf_managerid -> Merge Right Join (cost=14303.57..20534.23 rows=10979 width=76) Merge Cond: ("outer".keyf_workerid = "inner".keyf_workerid) -> Index Scan using users_workerid on users uw (cost=0.00..11586.52 rows=141125 width=23) -> Sort (cost=14303.57..14331.02 rows=10979 width=57) Sort Key: o.keyf_workerid -> Bitmap Heap Scan on orders o (cost=82.43..13566.75 rows=10979 width=57) Recheck Cond: (keyf_clientid = 8) -> Bitmap Index Scan on orders_clientid_idx (cost=0.00..82.43 rows=10979 width=0) Index Cond: (keyf_clientid = 8) -> Index Scan using address_building_pkey on address_building ab (cost=0.00..3.89 rows=1 width=37) Index Cond: ("outer".keyf_address_buildingid = ab.keyp_address_buildingid) -> Index Scan using location_pkey on "location" l (cost=0.00..4.46 rows=1 width=22) Index Cond: ("outer".keyf_locationid = l.keyp_locationid) -> Index Scan using supplier_pkey on supplier s (cost=0.00..4.48 rows=1 width=29) Index Cond: ("outer".keyf_supplierid = s.keyp_supplierid) -> Index Scan using invoice_pkey on invoice i (cost=0.00..4.51 rows=1 width=8) Index Cond: ("outer".keyf_invoiceid = i.keyp_invoiceid) (42 rows)