Limit (cost=433508.77..433508.77 rows=1 width=176) -> Sort (cost=433508.77..433508.77 rows=1 width=176) Sort Key: c_2.gii_circuitid, c_1.id -> Nested Loop (cost=168438.04..433508.76 rows=1 width=176) Join Filter: (c_1.id = vendor_gtt_pop.gtt_pop_id) -> Hash Join (cost=168438.04..433486.80 rows=1 width=148) Hash Cond: (c_1.id = c.id) -> Hash Join (cost=125957.20..388048.64 rows=788618 width=63) Hash Cond: (c_1.pop_support_vendor_id = v.id) -> Hash Join (cost=125518.15..377653.28 rows=788618 width=40) Hash Cond: (sg.id = cl.segment_id) -> Seq Scan on segment sg (cost=0.00..231189.42 rows=3482542 width=32) -> Hash (cost=115660.43..115660.43 rows=788618 width=16) -> Merge Join (cost=4.59..115660.43 rows=788618 width=16) Merge Cond: (cl.circuit_id = c_1.id) -> Index Only Scan using circuit_layout_idx on circuit_layout cl (cost=0.43..61739.87 rows=788618 width=8) Index Cond: (ordinal = 1) -> Index Scan using circuit_id_key on circuit c_1 (cost=0.42..41790.58 rows=909014 width=8) -> Hash (cost=325.69..325.69 rows=9069 width=27) -> Seq Scan on vendor v (cost=0.00..325.69 rows=9069 width=27) -> Hash (cost=42480.82..42480.82 rows=1 width=85) -> Nested Loop (cost=42469.41..42480.82 rows=1 width=85) Join Filter: (c.status = cst.id) -> Nested Loop (cost=42469.41..42479.37 rows=1 width=74) -> Nested Loop Left Join (cost=42468.98..42478.89 rows=1 width=70) Join Filter: (csc.id = cs.country_id) -> Nested Loop Left Join (cost=42468.98..42471.26 rows=1 width=68) -> Nested Loop (cost=42468.56..42470.81 rows=1 width=30) -> GroupAggregate (cost=42468.13..42468.15 rows=1 width=26) Group Key: c_2.gii_circuitid -> Sort (cost=42468.13..42468.14 rows=1 width=26) Sort Key: c_2.gii_circuitid -> Nested Loop (cost=6063.84..42468.12 rows=1 width=26) -> Nested Loop (cost=6063.41..42465.82 rows=5 width=30) -> Bitmap Heap Scan on circuit c_2 (cost=6062.99..42439.29 rows=10 width=26) Recheck Cond: (status >= 20) Filter: ((status <> ALL ('{160,999}'::integer[])) AND (status <> 160) AND (service_description = 28)) -> Bitmap Index Scan on ckt_stat_idx (cost=0.00..6062.99 rows=576315 width=0) Index Cond: (status >= 20) -> Index Scan using so_pid_idx on service_order so_1 (cost=0.42..2.65 rows=1 width=12) Index Cond: (product_id = c_2.product_id) Filter: (((ordertype_id <> 2) OR (status = 999)) AND ((ordertype_id <> 3) OR (status = 999))) -> Index Scan using master_service_order_id_key on master_service_order mso (cost=0.42..0.46 rows=1 width=4) Index Cond: (id = so_1.master_service_order_id) Filter: (client_id = 11615) -> Index Scan using service_order_id_key on service_order so (cost=0.42..2.64 rows=1 width=12) Index Cond: (id = (max(so_1.id))) -> Index Scan using client_site_pkey on client_site cs (cost=0.42..0.46 rows=1 width=46) Index Cond: (id = so.a_site_id) -> Seq Scan on country csc (cost=0.00..4.50 rows=250 width=6) -> Index Scan using circuit_product_id_idx on circuit c (cost=0.42..0.49 rows=1 width=12) Index Cond: (product_id = so.product_id) -> Seq Scan on circuit_status cst (cost=0.00..1.20 rows=20 width=19) -> Seq Scan on vendor_gtt_pop (cost=0.00..21.91 rows=3 width=12) Filter: (vendor_id = 12346)